Why? I am attempting to have what are, at the moment, capsule colliders, travel uphill. When they are kinematic, they go uphill as programmed. When they are non-kinematic, they drift slowly backward and then downhill (they start off on a more or less even plane). Why? I need them to be nonkinematic so that they detect the arrow the player shoots at them.
Here’s the script that’s directing them:
#pragma strict
var targetR : Transform;
var effRange : float;
var speed : float;
var canMove : boolean;
function Start ()
{
targetR = GameObject.FindWithTag("whiteElf").transform;
if(gameObject.name == "slowElf(Clone)")
{
speed = 0.25;
}else{
speed = 0.1;
}
effRange = 100.0;
canMove = true;
}
//The script sets the "target" (i.e. the game object which the present object is to follow around) to the white elf. The speed is set at 1.0 units/second.
//The effRange is the effective range within which present game object is to pursue the target. Outside the effective range, the present game object
//shall remain stationary.
//If the present object's name is "slowElf(Clone)", then the speed is lowered, so that it appears to be slower than its partner.
function Update ()
{
if(canMove)
{
transform.LookAt(targetR.transform.position);
transform.position = Vector3.Lerp(transform.position, targetR.position, Time.deltaTime * speed);
}
}