Advertisement
VelhoRabugento

Teste

Oct 21st, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.72 KB | None | 0 0
  1. if (velocidadeLimite >= maxVelocidade && Input.GetKey("w"))
  2.         {
  3.             velocidadeAtual = maxVelocidade;
  4.  
  5.             Debug.Log(velocidadeAtual);
  6.         }
  7.  
  8.         else
  9.         {
  10.             velocidadeAtual = 0f;
  11.         }
  12.  
  13.         if (velocidadeAtual >= maxVelocidade && Input.GetKey("s"))
  14.         {
  15.             velocidadeAtual = maxVelocidade;
  16.             velocidadeAtual--;
  17.  
  18.             if (velocidadeAtual <= 0f)
  19.             {
  20.                 velocidadeAtual = 0.02f;
  21.             }
  22.             else
  23.             {
  24.                 velocidadeAtual = 0f;
  25.             }
  26.         }
  27.  
  28. ------------------
  29.  private void OnTriggerStay(Collider other) {
  30.  
  31.         if (other.gameObject.tag == "IceFloor")
  32.         {
  33.             Debug.Log("Gelo!");
  34.  
  35.             if (velocidadeLimite >= maxVelocidade && Input.GetKey("w"))
  36.  
  37.                 velocidadeAtual = maxVelocidade;
  38.             else
  39.             {
  40.                 velocidadeAtual = 0f;
  41.             }
  42.  
  43.             Debug.Log("Aumentou velocidade");
  44.  
  45.             float moveHorizontal = Input.GetAxis("Horizontal");
  46.             float moveVertical = Input.GetAxis("Vertical");
  47.  
  48.             Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
  49.  
  50.             GetComponent<Collider>().material.dynamicFriction = 0.1f;
  51.  
  52.             GetComponent<Rigidbody>().AddForce(movement * velocidadeAtual * Time.deltaTime);
  53.  
  54.             //Mathf.Clamp(GetComponent<Rigidbody>().velocity.x, 0, 3);
  55.             //gameObject.GetComponent<Rigidbody>().velocity *= 0.99f;
  56.  
  57.             //velocidadeAtual = Mathf.Abs(gameObject.GetComponent<Rigidbody>().velocity.sqrMagnitude / 3.6f);
  58.  
  59.         }
  60.  
  61.  
  62.         else if (other.gameObject.tag == "IceFloor")
  63.         {
  64.             Debug.Log("Gelo!");
  65.  
  66.             if (velocidadeAtual >= maxVelocidade && Input.GetKey("s"))
  67.  
  68.             velocidadeAtual = maxVelocidade;
  69.             velocidadeAtual--;
  70.  
  71.             if (velocidadeAtual <= 0f)
  72.             {
  73.                 velocidadeAtual = 0.02f;
  74.             }
  75.             else
  76.             {
  77.                 velocidadeAtual = 0f;
  78.             }
  79.  
  80.             Debug.Log("Diminuiu velocidade");
  81.  
  82.             float moveHorizontal = Input.GetAxis("Horizontal");
  83.             float moveVertical = Input.GetAxis("Vertical");
  84.  
  85.             Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
  86.  
  87.             GetComponent<Collider>().material.dynamicFriction = 0.5f;
  88.             GetComponent<Rigidbody>().AddForce(movement * velocidadeAtual / 2 * Time.deltaTime);
  89.  
  90.             //gameObject.GetComponent<Rigidbody>().velocity *= 0.33f;
  91.  
  92.             //velocidadeAtual = Mathf.Abs(gameObject.GetComponent<Rigidbody>().velocity.sqrMagnitude / 3.6f);
  93.         }
  94.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement