Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Field jump.rb is never assigned to, and will all ways have its defualt value null

$
0
0
I don't know what im doing wrong and aparently you get this error when you don't use the variable but im using it multiple times in my script. using UnityEngine; using System.Collections; public class Jump : MonoBehaviour { private bool OnGround; private Rigidbody rb; void Start() { OnGround = true; rb = GetComponent(); } void Update() { if(OnGround) { if (Input.GetButton("Jump")) { rb.velocity = new Vector3(0.0f, 10f, 0.0f); } else { rb.velocity = new Vector3(0.0f, 0f, 0.0f); OnGround = false; } } } void OnCollisonEnter(Collision other) { if (other.gameObject.CompareTag("ground")) { OnGround = true; } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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