1
私はオブジェクトと2つのGUIテクスチャボタンを持っています。左のボタンを押すとオブジェクトを左に、右のボタンを押しながらオブジェクトを左に回転させたいと思います。ボタンをクリックしてゲームオブジェクトを回転させる
アイデア?
オブジェクトをドラッグすると動作するスクリプトがあります。私は重要な部分を掲載します:
function Start()
{
var angles = transform.eulerAngles;
x = angles.y;
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
function LateUpdate()
{
if (isMouseOverGuiTexture()) return;
if (target && Input.GetMouseButton(0))
{
//0.1 represents the sensitivity of the mouse
x += Input.GetAxis("Mouse X") * xSpeed *0.1; //x rotation
//y -= Input.GetAxis("Mouse Y") * ySpeed *0.1; //y rotation
//y = ClampAngle(y, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.900528, 8.829305, -distance+0.49548)+ target.position;
transform.rotation = rotation;
transform.position = position;
}
}
どのようなAPIですか? javascriptのように見える? – trojanfoe
unity 3dとコードはjavascriptです。 –
私は自分の質問を編集し、その答えを追加しました。私が間違って何かをした場合は申し訳ありません。 –