So I made this script that is attached to an object with a boxcolider and rigidbody.
When the Player collides with the object(it collides with the player) it executes a script on an enemy, the script makes the enemy move constantly along the x-axis, But how do I make it run costantly?
I use transform.Translate (speed*Time.deltaTime,0,0);
the script on the enemy:
public class Boss : MonoBehaviour {
public float damage = 1f;
public float speed = 10;
// Use this for initialization
void Update () {
}
// Update is called once per frame
public void Run () {
transform.Translate (speed*Time.deltaTime,0,0); //move
the script on the object that checks for a collision:
public class RunTrigger : MonoBehaviour {
public Boss boss;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag(“Player”)){
boss.Run();