debut de script pour les humains

This commit is contained in:
MAM 2015-08-13 13:28:52 -04:00
parent 6152a68a3d
commit 3bfee9df14

View File

@ -3,13 +3,52 @@ using System.Collections;
public class Human : MonoBehaviour { public class Human : MonoBehaviour {
//vitesse de deplacement
public float humanSpeed;
//Le temps avant de faire un changement de direction
public int duree;
private int timer = 0;
private Rigidbody rb;
private float horizontal=10.0f;
private float vertical=0.0f;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
rb = GetComponent<Rigidbody> ();
} }
// Update is called once per frame float changementSens()
void Update () { {
//Faire un changement de sens
if (Random.value > 0.5) {
return -1.0f;
}
else {
return 1.0f;
}
} }
void FixedUpdate()
{
if (timer == duree) {
if (Random.value > 0.5) {
horizontal = 10.0f*changementSens();
vertical=0.0f;
print (horizontal);
} else {
vertical = 10.0f*changementSens();
horizontal=0.0f;
print (vertical);
}
timer=0;
}
timer += 1;
Vector3 mouvement = new Vector3 (horizontal,0.0f,vertical);
rb.AddForce (mouvement);
}
} }