Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Please Help! Problems With AddRelativeForce in slow motion

$
0
0
Hi, Here is my code for slow-motion (based off of the brackeys tutorial): public float slowTime = 2.0f; public float slowAmount = 0.01f; public bool turnOn = false; public GameObject shooter; void Update(){ if (Input.GetKeyDown (KeyCode.E)) { turnOn = !turnOn; if (turnOn) { SlowMotion (); } else { NormalSpeed (); } } } public void SlowMotion(){ Time.timeScale = slowAmount; Time.maximumDeltaTime = Time.timeScale * slowAmount; Time.fixedDeltaTime= Time.timeScale * slowAmount; //Debug.Log ("Clicked"); } public void NormalSpeed(){ Time.timeScale = 1.0f; Time.fixedDeltaTime = Time.timeScale * 0.01f; //Debug.Log ("Clicked"); } Here is my code for shooting balls: public Rigidbody Bullet; public float Force = 5000.0f; public float ballsShot = 0.0f; public GameObject cam; public void Update () { if(Input.GetButtonDown("Fire1")){ var clone = Instantiate (Bullet, transform.position, transform.rotation); clone.AddRelativeForce (new Vector3 (0.0f, 0.0f, Force)); if (cam.GetComponent ().turnOn == false) { //clone.AddRelativeForce (new Vector3 (0.0f, 0.0f, Force*10)); } Destroy (clone, 50.0f); ballsShot++; } } The slow-mo works perfectly fine, this is not an error with "laggy" slow-motion or anything like that... However, whenever I shoot the ball in slow-motion, I expect it to go flying forward like it would in non-slow motion... but instead it just falls to the ground as if no force was being added. I would really, really, really, appreciate any answer/solution to this problem! Thanks in advance!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>