transform.translate gets 2x more than meant to
hi, so i've been stuck with that weird bug as soon as i started unity:
so we're starting with this: one camera with 5 rays to have some spatial sense, 3 more beams on each axes with transform.up/right/right to have some debug info and a start object for refrence, being 1x1x1 in size, the camera starts looking forwards and when pressing "W" it can go forwards.
problem is, this happens when looking straight down:
it makes you go backwards somehow, the translate function doubles the angle it gets and thinks you did a 180 instead of ding a 90° pitch, it happens too when looking left, it's really weird.
here's my code:
pitch += speedV * Input.GetAxis("Mouse Y");
yaw -= speedH * Input.GetAxis("Mouse X");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
//Moving the camera
transform.Translate(transform.forward * forwardSpeed * Time.deltaTime);
transform.Translate(transform.right * -leftSpeed * Time.deltaTime);
transform.Translate(transform.up * verticalSpeed * Time.deltaTime);
the speeds are simple float values being positive when pressing W and negative when pressing S and 0 when neither are pressed, i don't see how i could've crapped it up, something is up with that function
Your answer
![](https://koobas.hobune.stream/wayback/20220613030656im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Character goes out of view the first time it translates. 0 Answers
Moving an object smoothly over predetermined distance without defining begin and end points 0 Answers
transform.Translate() effect is being reverted 0 Answers
Input.GetMouseButtonDown() translates automatically to Mobile Platforms? 2 Answers