【发布时间】:2014-12-21 07:51:04
【问题描述】:
更新的代码..问题是我不能移动球只有当我按住 E 按钮而不是我使用 WASD 或箭头来移动球时......当我按住 Q 时相机 2 激活并且我可以移动带有 WASD 或箭头的球...但是该角度的右轴...就像那个游戏的平衡...我不想握住 E 或 Q 只是为了改变相机并正确地移动球到那个角度球的右轴,但不按住相机按钮
使用 UnityEngine; 使用 System.Collections;
公共类 controlPlayer : MonoBehaviour {
public float viteza ; // this is speed
;
void Start(){
}
void Update()
{
if(Input.GetKey(KeyCode.Q) ) // if i hold Q the camera 2 activates and with WASD i can move the ball
{
float miscaOrizontal = Input.GetAxis("Horizontal");
float miscaVertical = Input.GetAxis("Vertical");
Vector3 miscare = new Vector3(miscaVertical,0.0f,(-miscaOrizontal)); //also here i chande the axis for the camera 2
rigidbody.AddForce(miscare * viteza * Time.deltaTime);
}
if(Input.GetKey(KeyCode.E) ) // here when i press E the camera 1 activates and alos i can move the ball if i keep pressing E
{ float miscaOrizontal2 = Input.GetAxis("Horizontal");
float miscaVertical2 = Input.GetAxis("Vertical");
Vector3 miscare2 = new Vector3(miscaOrizontal2,0.0f,miscaVertical2); // here are the controls for the ball for the camera ..i had to change the axis here..
rigidbody.AddForce(miscare2 * viteza * Time.deltaTime);
}
}
}
}
【问题讨论】:
标签: unity3d