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

I'm trying to get the character to jump, is it because the trigger key hasn't been inputed correctly?

$
0
0
This is the code I'm using #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.Space) && isFalling == false) { rigidbody.velocity.y = jumpHeight; } isFalling = true; } function onCollisionStay () { isFalling = false; } I'm working on my coding skills and I've tried just about everything I know, outside of rewriting the entire thing and no one else could figure it out. I was wondering if someone here could show me the fix.

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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