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

Can someone help me fix this coding error?

$
0
0
Before I show the code, I would like to explain I did try to fix it and my fix worked kind of, but caused other errors to show up and I just didn't feel like typing all of the errors out on here and I already know it wasn't the right kind of fix I needed. Anyways, here is the code I used #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)); { Rigidbody.velocity.y = jumpHeight; } isFalling = true; } And the error that showed up is "An instance of type 'UnityEngine.Rigidbody' is required to access non static member 'velocity'"

Viewing all articles
Browse latest Browse all 1875

Latest Images

Trending Articles



Latest Images

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