rotate gameobject on z axis with mouse x movement
I have looked at and tried everything posted but can't seem to get anything to work. I have a boat controller that I steer with the mouse ( it's basically the car controller with a TPS camera) I was able to get the boat to rise up with speed, but when I turn the boat with the mouse movement, I want the boat to tilt into the turn - along the objects Z axis. the script below works somewhat in that the boat tilts but up and down. I don't want up and down or side to side I want it to tilt along its length to bank left or right
var speed : float = 5.0; //how fast the object should rotate
function Update(){
transform.Rotate(Vector3(Input.GetAxis("Mouse X"), 0) * Time.deltaTime * speed);
}
ok, I have figured it out somewhat, but it banks in the wrong direction. What do I need to change to reverse the angle it currently banks?
transform.Rotate(0, 0, (Input.GetAxis("$$anonymous$$ouse X")) * Time.deltaTime * speed);
Answer by shadowpuppet · Jun 16, 2017 at 01:36 AM
wow that was simple, just add a minus sign
transform.Rotate(0, 0, -(Input.GetAxis("Mouse X")) Time.deltaTime speed );
Your answer
Follow this Question
Related Questions
Quaternion.Slerp rotating only 90 degrees. 2 Answers
Can i use animation timeline like slider value to get access using for ex. mouse Y value. 1 Answer
Rotate object around X axis 1 Answer
3D side-scrolling shooter: Getting the player to aim at the mouse onscreen. (C#) 0 Answers
strange rotation in 2d 0 Answers