hi at all. i am new in unity world ;) now i am working to behaviour of enemy in my game. i have to do a enemy (that have a character controller component) that follow a target. for do that i rotate enemy in direction on target with
characterController.LookAt(target.position) and this work great.
but after i have to move enemy in target direction. i tried to do something using function transormDirection but doesn't work following my code:
GameObject target;
float speed;
CharacterController character;
Vector3 direction;
void Start () {
speed = 0.2F;
target=GameObject.Find("CubePath3");
character = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update () {
direction = transform.TransformDirection(target.transform.position);
transform.LookAt(target.transform.position);
character.SimpleMove(direction*speed);
}
somebody can help me? ;) thanks a lot ;)