So, basically, I’m trying to get the camera and player to work correctly. The game starts out as a normal looking 2D game. but when you press the ‘R’ key, the camera rotates, which gives you a different view of the ground platform. The player is supposed to always be facing the camera, since it’s rotation is always set to the camera’s rotation. The problem is that it only faces the camera when the ‘R’ key is being pressed. When the key is not being pressed it either reverts back to it’s original rotation, or it stays in the rotation changed by the camera until you move. That’s also another problem. The player is supposed to go left and right when the ‘LEFT’ and ‘RIGHT’ arrow keys are pressed. It works, but when theplayer rotates, it still goes in the default right and left direction, meaning it goes back to facing the front (the rotation is set to 0, 0, 0). So I need a way to make sure that when you move right, it’s the right relative to the camera’s rotation, not the player’s position. I know this is kinda long, and might be hard to understand, but how do I implement these concepts?
Do you always want the player to be facing the camera or only if R is held down? Right now, the code you have written has the player rotation only changed when R is pressed.
As the player is a rigidbody, you cannot/shouldn’t set the rotation directly on the entity object as it is overridden by the physics engine internal simulation. This makes it a little awkward.
In this case, as the collision is a uniform box, you can separate the visual representation from the physics object which will work in this case. The visual representation can always face the camera in this case while the rigidbody is unaffected.
I tried to implement it, but it didn’t work. It doesn’t show any errors, but the model isn’t rotating. Did I do something wrong, or is this an engine glitch?