Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

What is causing the object to fly upwards?

$
0
0
Basically I just want to be able to make the object jump, but whenever I start the game, the ball ends up floating up. I believe the issue lies within either line 20 or 17, but I could very well be mistaken. #pragma strict var rotationSpeed = 100; var jumpHeight = 8; private var isFalling = false; function Update () { //Ball rotation. var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; rotation *= Time.deltaTime; var rigidbody: Rigidbody = gameObject.GetComponent(Rigidbody) as Rigidbody; GetComponent. ().AddRelativeTorque (Vector3.back * rotation); if (Input.GetKeyDown(KeyCode.W) && isFalling == false); { rigidbody.velocity.y = jumpHeight; } isFalling = true; } function onCollisionStay () { isFalling = false; }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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