diff --git a/Assets/Scripts/Human.cs b/Assets/Scripts/Human.cs index 5baad15..331b802 100644 --- a/Assets/Scripts/Human.cs +++ b/Assets/Scripts/Human.cs @@ -3,13 +3,52 @@ using System.Collections; 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 void Start () { - + rb = GetComponent (); } - // Update is called once per frame - void Update () { - + float changementSens() + { + //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); + } + + }