- Home /
RigidBodys and Scripts equals Error.
Imagine:A cube with a Rigidbody, the Player.
Problem: When cube turns completely backward, S (backwards button) is forward and W, vice versa. #pragma strict var moveSpeed : float; var turnSpeed : float; function Update(){ if(Input.GetButton("TurnLeft")) { transform.Rotate(-transform.up * turnSpeed * Time.deltaTime); } if(Input.GetButton("Jump")) { transform.Translate(transform.up * 5 * Time.deltaTime); } if(Input.GetButton("Forward")) { transform.Translate(transform.forward * moveSpeed * Time.deltaTime); } if(Input.GetButton("Backward")) { transform.Translate(-transform.forward * moveSpeed * Time.deltaTime); } if(Input.GetButton("TurnRight")) { transform.Rotate(transform.up * turnSpeed * Time.deltaTime); } }
Help! :D
Answer by Berenger · Jun 06, 2012 at 02:28 AM
The problem is probably your camera. Is it a child of the cube ? A little advice, use another object (cube, cylynder or whatever) to make a nose for your charater, or anything that shows what is the front. It will prevent from being confused.
Answer by chicka123 · Jun 06, 2012 at 10:17 PM
Well, I found out the problem. Im moving on a world axis, not local. I don't know how to switch it to local. If there is no replies, im reposting this.