Advertisement
VelhoRabugento

Teste2

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