Hi there, I have been trying this out for a while and I cannot figure this out. I want to use addForce instead of it transforming towards the player. I basically have an enemy ball that I want following me, the below code works but I want it to “roll” instead of sliding. I have my “player” controlled by the mouse,which is also a ball, like this…
var speed = 300;
Screen.lockCursor = true;
function Update()
{
rigidbody.AddForce(Vector3(Input.GetAxisRaw("Mouse X"), 0, Input.GetAxis("Mouse Y"))* Time.deltaTime * speed);
}
and this works fine, now how could I implement the addForce to my enemy. I will slowly add more “AI” to it later…Enemy script that works but sliding instead of rolling…
var speed = 5;
var plyr : GameObject;
function Update()
{
var direction = plyr.transform.position - transform.position;
transform.position += direction.normalized * speed * Time.deltaTime;
}