Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (gameController.everyoneCanMove())
     {
         float xTranslation = Random.Range(speedTendency, 1.0f) * cr.GetMovementSpeed() * Time.deltaTime;
         float carTendency;
         if (this.transform.position.y < targetedCarHeight)
         {
             carTendency = Random.Range(0, 0.5f);
         }
         else
         {
             carTendency = Random.Range(-0.5f, 0);
         }
         float yTranslation = (directionalTendency * Random.Range(0, 1.0f) + carTendency) * cr.GetMovementSpeed() * Time.deltaTime;
         transform.Translate(new Vector3(xTranslation, yTranslation));
     }
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (gameController.everyoneCanMove())
     {
         float horizontal = Input.GetAxis("Horizontal");
         float vertical   = Input.GetAxis("Vertical");
         if (horizontal == 0 && vertical == 0)
         {
             animator.SetBool("isRunning", false);
         }
         else
         {
             animator.SetBool("isRunning", true);
         }
         this.transform.Translate(new Vector3(horizontal, vertical, 0) * cr.GetMovementSpeed() * Time.deltaTime);
     }
     else
     {
         animator.SetBool("isRunning", false);
     }
 }