- Home /
This question was
closed Nov 27, 2018 at 02:40 PM by
$$anonymous$$ for the following reason:
Other
Question by
$$anonymous$$ · Feb 23, 2015 at 01:06 PM ·
c#movementenemy
Need help trying to make my enemy keep constant movement
I wrote a code to were my script makes the enemy move but when the enemy move down at the player he just stop I want the enemy to push the enemy the the other way around here Is my enemy script and the player is using a charactercontroller
public class enemy : MonoBehaviour {
public float speed;
void Start ()
{
rigidbody.velocity = transform.forward * speed;
}
}
Comment
Answer by gameplay4all · Feb 23, 2015 at 01:10 PM
Place it in the FixedUpdate() or Update() function! :)
Answer by hexagonius · Feb 23, 2015 at 01:45 PM
Pushing a character controller is not possible by means of physically pushing like rigidbodies. You'll need to move it on collision or something like that.
Gameplay4all is right. Read about Start, Update and FixedUpdate, where Start is only executed once and for setup stuff