When I place my enemy into the scene and play the enemy follows be by floating around and doesn't stick to the ground.
Here is my code:
var Distance;
var Target : Transform;
var lookAtDistance = 25.0;
var chaseRange = 15.0;
var attackRange = 1.5;
var moveSpeed = 5.0;
var Damping = 6.0;
var attackRepeatTime = 1;
var TheEnemyDamage = 40;
private var attackTime : float;
var controller : CharacterController;
var gravity : float = 20.0;
private var MoveDirection : Vector3 = Vector3.zero;
function Start()
{
attackTime = Time.time;
}
function Update ()
{
Distance = Vector3.Distance(Target.position, transform.position);
if (Distance < lookAtDistance)
{
lookAt();
}
if (Distance > lookAtDistance)
{
renderer.material.color = Color.green;
}
if (Distance < attackRange)
{
attack();
}
else
if (Distance < chaseRange)
{
chase();
}
}
That is not all of it but can someone tell me if I should include the whole script.
I also tried adding a rigid body to it but that wont allow the enemy to move at all.
↧