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

Unity, 2D AI Error

$
0
0
Hello, The problem i have is that the AI Rotates 3 dimensionally when i need it in to 2. I need it to rotate on the sprites centre point not so that it rotates on its side. Its quite difficult to explain here is a picture: ![alt text][1] [1]: /storage/temp/20249-2d+error.jpg Code: #pragma strict var target : Transform; var moveSpeed = 3; var rotationSpeed = 3; var myTransform : Transform; function Awake() { myTransform = transform; } function Start() { target = GameObject.FindWithTag("Player").transform; } function Update () { myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; }

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>