Moving character depending on where the camera is facing
I had already done a lot of research before, and could not find a clear solution to my problem.
I can post my code if any of you guys need it.
So first of all, I'm making a 3D top-down shooter. My camera rotates around the player, and whenever I press a button forward, the character moves forward. But it moves on the world axis. I want it to move in the local axis. But this isn't possible since the character is always facing a different direction because I made it so that the character is always facing the location of the mouse.
So, what I need it to do is have the character move in the direction opposite the camera when pressing forward (W), and left or right with the keys that correspond to it.
Almost forgot to mention, I don't know if this is relevant or not, but the camera is facing the character at an angle, so it has a top and side view of the character.
Answer by JinPark · Mar 23, 2018 at 05:06 AM
I finally got this thing working. For those of you who want to know the answer, let me explain.
So, I created an empty object (let's call this obj1), the empty object will rotate and move whenever the player presses the desired button.
There is also another empty object (let's call this obj2), this object will copy the position of the obj1, but not the rotation. Obj2 also serves as a pivot point for rotating the camera. The camera is a child of obj2, and rotates whenever the player presses the left or right rotation button.
The important fact to remember is that rotation of obj1 and the camera must match because they are initialized individually.
Your answer
Follow this Question
Related Questions
3D objects appear behind 2D on mobile, but in correct order in editor 1 Answer
How to fix an object to the center of the screen? 0 Answers
How to bring UI element infront of other objects? 0 Answers
How to make player move relative to camera 0 Answers
I get errors that say GameCoreXbox after installing Cinemachine 0 Answers