Game Development Asked by 1234567890 on November 13, 2020
I am making a basic movement script based off of the built in playercontroller in Unity. I am trying to get the Player gameobject to move forward based on its own rotation (i.e. if it is rotated to 90 degrees, it will go forward in the direction it is facing and not based off of its position values), but I can’t figure out how to change it.
How can I do this?
EDIT:
I figured it out. I just had to multiply the playercontroller’s movement by player rotation.
I think what you need is the value transform.forward This is a normalized vector that will always point in the same direction as the object's blue arrow in the scene view. Feeding this into the character controller's Move method will move the object forward, regardless of rotation.
Do note that the character controller is only designed to function with an objective 'down' aligned to the y-axis. This means that if you rotate on any axis but the y-axis, it can lead to some strange results.
Answered by Weckar E. on November 13, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP