Есть скрипт
Код
public class randomizer : MonoBehaviour {
public void fear()
{
int rand = Random.Range(0, 100);
if (rand<55){
Debug.Log("нападают");
}
if (rand >= 55) {
Debug.Log("убегают");
}
}
}
Каким образом можно запустить следующий срипт
Код
public class enemy : MonoBehaviour {
private Vector3 Player;
private Vector2 PlayerDirection;
private float Xdif;
private float Ydif;
private float speed;
private float distance;
private bool stun;
private float stuntime;
// Use this for initialization
void Start () {
stuntime = 0;
stun = false;
speed = 6;
}
// Update is called once per frame
public void Update () {
distance = Vector2.Distance (Player, transform.position);
Player = GameObject.Find ("Player").transform.position;
if (stuntime > 0) {
stuntime -=Time.deltaTime;
} else {
stun = false;
}
if (distance < 25 & !stun) {
Xdif = Player.x - transform.position.x;
Ydif = Player.y - transform.position.y;
PlayerDirection = new Vector2 (Xdif, Ydif);
GetComponent<Rigidbody2D>().AddForce (PlayerDirection.normalized * speed);
}
}
void OnCollisionEnter2D(Collision2D Playerhit){
if (Playerhit.gameObject.tag == "Player") {
stun = true;
stuntime = 1;
}
}
}
Например в месте где указано Код
Debug.Log("нападают");