// Update is called once per frame at a fixed time void FixedUpdate() { PlayerTransform.Rotate(0, Input.GetAxis("Horizontal") * 2, 0); //sets rotation to right or left direction (q,d, fleche droit , fleche gauche) /// PlayerTransform.Rotate(0, 0, Input.GetAxis("Vertical")); Vector3 targetVelocity = new Vector3(0, 0, Input.GetAxis("Vertical")); //makes player go foward or back whit (z,s,fleche avant , fleche arriere) targetVelocity = PlayerTransform.TransformDirection(targetVelocity); targetVelocity = targetVelocity * speed; Vector3 velocity = _rigidbody.velocity; Vector3 velocityChange = targetVelocity - velocity; velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); // makes sure we dont change direction whene we are moving velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); // velocityChange.y = 0; _rigidbody.AddForce(velocityChange, ForceMode.VelocityChange); if (Input.GetButton("Jump") && grounded == true) //if player preses space bar then jump { _rigidbody.velocity = new Vector3(velocity.x, CalculateJump(), velocity.z); } _rigidbody.AddForce(new Vector3(0, -gravity * _rigidbody.mass, 0)); //gravity grounded = false; TargetCoin = GameObject.FindGameObjectWithTag("Coin").transform; OtherScriptToAccess = TargetCoin.GetComponent <CoinRotation>(); //the scrip asociated to the }
public void TogglePauseMenu() { Time.timeScale = Time.timeScale == 0 ? 1 : 0; //pauza pauseMenu.SetActive(!pauseMenu.activeSelf); CoinRotation.changeStop(true); //zaleznie od stanu zmien go na przeciwny moveJoystick.enabled = !moveJoystick.isActiveAndEnabled; boost.enabled = !boost.isActiveAndEnabled; }
/* * public void Death() { * player.transform.position = respawnPoint.position; * Rigidbody rigid = player.GetComponent<Rigidbody>(); * rigid.velocity = Vector3.zero; * rigid.angularVelocity = Vector3.zero; * }*/ public void PlayAgain() //zaladuj wybrany level - dla ,,Play Again" z Pause Menu { SceneManager.LoadScene(SceneManager.GetActiveScene().name); Time.timeScale = 1; CoinRotation.changeStop(false); //Niewazne jaki byl stan wlacz obrot pieniazkow }
private void LoadLevel(string sceneName) //zaladuj wybrany level { SceneManager.LoadScene(sceneName); Time.timeScale = 1; CoinRotation.changeStop(false); //Niewazne jaki byl stan wlacz obrot pieniazkow }