Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Moving player in camera direction

$
0
0
First I am a little bit sorry because it is a very classical question but actually I did not find an appropriate answer to my problem which is: I want my player to take the camera direction when moving fwd and bwd. So I could do: Vector3 targetDirection = Camera.main.transform.forward; Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up); It works but this way it does not move horitontally. This could be solved by catching horizontal and vertical axis: Vector3 targetDirection = new Vector3(horizontal, 0f, vertical); But now my player does not follow camera direction. Any idea ?

Viewing all articles
Browse latest Browse all 171066

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>