Hi, I am currently scripting a vehicle, and this is the base code, of course, I am going to modifiy it, but for instance this is working, just if multiple keys are not pressed at once, if W and A are pressed at the same time nothing happens, help?Thanks in advance, here’s the code:
if(Input.GetKey(KeyCode.W))
{
rigidbody.AddForce(transform.forward * CarSpeed, ForceMode.VelocityChange);
}
if(Input.GetKey(KeyCode.S))
{
if(CurPos!=LastPos)
rigidbody.drag=5;
}
if(Input.GetKey(KeyCode.A))
{
CarPosY-=0.2f;
rigidbody.transform.eulerAngles=new Vector3(CarPosX,CarPosY,CarPosZ);
}
if(Input.GetKey(KeyCode.D))
{
CarPosY+=0.2f;
rigidbody.transform.eulerAngles=new Vector3(CarPosX,CarPosY,CarPosZ);
}
LastPos=CurPos;