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
统一3d和代码的JavaScript。 –
我编辑了我的问题,并添加了答案。对不起,如果我做错了什么。 –