0

How to make the player face the direction he's moving, and make the camera follow him also

I'm using unity, trying to make an open world 3d game, similar to grand theft auto, or minecraft. I'm trying to figure out how to get my player to move right, and turn the direction he's moving. And I need to also figure out how to get the camera to stay on him. So far the camera only follows him forwards and backwards and he doesn't spin when he turns. any help would be appreciated

18th May 2018, 4:27 AM
Shon Gosnell
Shon Gosnell - avatar
1 ответ
+ 2
Hi Shon Gosnell, I recommend using the FirstPersonController or ThirdPersonController, Depending on where you want the camera. It is located in Unity's standard assets (you may need to download it from the Unity asset store if you don't have it). The controllers provide smooth movement using wasd to move. If you want to code it yourself, place the camera in the starting position of the player. Make sure the camera is a component of the player and is tagged "Main". The camera being a component of the player will make the camera follow regardless of where the player moves. Then, with a key event you can turn the character. If D is pressed, rotate the transform of the player to the right. The movement will look clonky but, it's a start. Key events can be something like: If (Input.getKey(KeyCode.D)) transform.Rotate( // rotation applied );
23rd May 2018, 2:36 AM
Rrestoring faith
Rrestoring faith - avatar