Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (velocidadeLimite >= maxVelocidade && Input.GetKey("w"))
- {
- velocidadeAtual = maxVelocidade;
- Debug.Log(velocidadeAtual);
- }
- else
- {
- velocidadeAtual = 0f;
- }
- if (velocidadeAtual >= maxVelocidade && Input.GetKey("s"))
- {
- velocidadeAtual = maxVelocidade;
- velocidadeAtual--;
- if (velocidadeAtual <= 0f)
- {
- velocidadeAtual = 0.02f;
- }
- else
- {
- velocidadeAtual = 0f;
- }
- }
- ------------------
- private void OnTriggerStay(Collider other) {
- if (other.gameObject.tag == "IceFloor")
- {
- Debug.Log("Gelo!");
- if (velocidadeLimite >= maxVelocidade && Input.GetKey("w"))
- velocidadeAtual = maxVelocidade;
- else
- {
- velocidadeAtual = 0f;
- }
- Debug.Log("Aumentou velocidade");
- float moveHorizontal = Input.GetAxis("Horizontal");
- float moveVertical = Input.GetAxis("Vertical");
- Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
- GetComponent<Collider>().material.dynamicFriction = 0.1f;
- GetComponent<Rigidbody>().AddForce(movement * velocidadeAtual * Time.deltaTime);
- //Mathf.Clamp(GetComponent<Rigidbody>().velocity.x, 0, 3);
- //gameObject.GetComponent<Rigidbody>().velocity *= 0.99f;
- //velocidadeAtual = Mathf.Abs(gameObject.GetComponent<Rigidbody>().velocity.sqrMagnitude / 3.6f);
- }
- else if (other.gameObject.tag == "IceFloor")
- {
- Debug.Log("Gelo!");
- if (velocidadeAtual >= maxVelocidade && Input.GetKey("s"))
- velocidadeAtual = maxVelocidade;
- velocidadeAtual--;
- if (velocidadeAtual <= 0f)
- {
- velocidadeAtual = 0.02f;
- }
- else
- {
- velocidadeAtual = 0f;
- }
- Debug.Log("Diminuiu velocidade");
- float moveHorizontal = Input.GetAxis("Horizontal");
- float moveVertical = Input.GetAxis("Vertical");
- Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
- GetComponent<Collider>().material.dynamicFriction = 0.5f;
- GetComponent<Rigidbody>().AddForce(movement * velocidadeAtual / 2 * Time.deltaTime);
- //gameObject.GetComponent<Rigidbody>().velocity *= 0.33f;
- //velocidadeAtual = Mathf.Abs(gameObject.GetComponent<Rigidbody>().velocity.sqrMagnitude / 3.6f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement