- Home /
Question by
coolfireking2 · Jan 05, 2014 at 06:58 PM ·
2dai4.3
Unity, 2D AI Error
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:
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;
}
2d error.jpg
(160.9 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613125623im_/https://answers.unity.com/themes/thub/images/avi.jpg)