addForce on AI

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;
}

why are you using the php code formatting? Just wrap the code in tags.

sorry I thought that was the code tag, overlooked it :frowning:

Just set FreezeRotation on your enemy’s rigidbody to True.

Sorry, I think I wrote it wrong, I meant I want the enemy rolling instead of sliding by using the addforce, Ive been playing now and almost got it except its only rolling on the X axis towards me. I think if I set the Y axis to face me all the time, it should work then, so far I got this. Thanks.

var speed = 5;
var plyr : GameObject;

function Update() 
{
	var direction = plyr.transform.position - transform.position;
	rigidbody.AddForce(-transform.position * speed * Time.deltaTime);
}

Had a bit of a dumb moment there, I cant use LookAtPlayer cause its rolling and the axises change all the time :frowning: any ideas?