言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Gyroscope.gravity

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public var gravity: Vector3;
public Vector3 gravity;
public gravity as Vector3

Description

デバイスの参照フレームでの正確な重力加速度のベクトルを返します

	var movementScale: float;

	function Update() {
		// A "spirit level" - the dot product of the gravity and the Y axis (ie, Vector3.up)
		// is a measure of how far the device is from level on that axis (it will be zero
		// if the device is perfectly level). This value can be used to position an object
		// to act as the "bubble".
		var pos = transform.position;
		pos.y = Vector3.Dot(Input.gyro.gravity, Vector3.up) * movementScale;
		transform.position = pos;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public float movementScale;
    void Update() {
        Vector3 pos = transform.position;
        pos.y = Vector3.Dot(Input.gyro.gravity, Vector3.up) * movementScale;
        transform.position = pos;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public movementScale as float

	def Update() as void:
		pos as Vector3 = transform.position
		pos.y = (Vector3.Dot(Input.gyro.gravity, Vector3.up) * movementScale)
		transform.position = pos