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

An object reference is required error how can i fix it?

$
0
0
I get two errors saying that "An object reference is required for the non-static field, method, or property ' UnityEngine.Transform.position.get" and "An object reference is required for the non-static field, method, or property ' UnityEngine.Transform.rotation.get" The code is meant to make a bullet and shoot it forward. I'm new to C# so if its an epic fail don't laugh and stuff :) Thanks using UnityEngine; using System.Collections; public class Breakthewall : MonoBehaviour { public Rigidbody bullet; public float power = 1500f; void Update () { if (Input.GetButtonUp ("Fire1")){ Rigidbody instance = Instantiate(bullet, Transform.position, Transform.rotation) as Rigidbody; Vector3 fwd = transform.TransformDirection(Vector3.forward); instance.AddForce (fwd * power); } } }

Viewing all articles
Browse latest Browse all 7934

Latest Images

Trending Articles



Latest Images

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