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);
}
}
}
↧