Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

AddForce not working

$
0
0
I am currently using this script to make a monster chase the player: #pragma strict var target : Transform; var moveSpeed = 240; var rotationSpeed = 180; var myTransform : Transform; var myRigidbody : Rigidbody; function Awake() { myTransform = transform; } function Start() { target = GameObject.FindWithTag("Player").transform; myRigidbody = rigidbody; } function Update () { myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); myRigidbody.AddForce(myTransform.forward * moveSpeed * Time.deltaTime); } For some reason though the monster doesn't actually move. It turns to look at the player but doesn't chase. Does anyone know the reason?

Viewing all articles
Browse latest Browse all 1264

Trending Articles