- Home /
Question by
Shadow9361 · Sep 03, 2012 at 12:44 AM ·
aienemygravity
Applying Gravity to AI on chase
Hey,
im building AI for my game and im using pathing nodes to move the ai around the map, works great, how ever when the player comes in range and the AI chase they end up flying and no gravity such effects are being applied here is the function
function Chase ()
{
var range = Vector3.Distance(player.position, transform.position);
if (range <= killRange)
{
Debug.Log("Killed Player");
}
else if (range <= chaseRange)
{
transform.LookAt(player);
var moveDirection : Vector3 = transform.TransformDirection(Vector3.forward);
walkDirection.y-=gravity*Time.deltaTime;
control.Move(moveDirection * Time.deltaTime * speed);
}
}
any help on getting gravity to work would be great help. Thanks in advance.
P.S when the player get out of chase range the AI drops to the ground like a lead ball
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613080535im_/https://answers.unity.com/themes/thub/images/avi.jpg)