Hello and thanks in advance. I am trying to program a scene that when the player collides with an object, the object is then picked up and begins to rotate around the player in a circular pattern around the different vertices. If anyone can point me in the correct direction I would be very much appreciative and send you lots of cookies. So far I've managed to just have the player destroy the object (by making it disappear), and I get the following error. UnassignedReferenceException: The variable b of _x has not been assigned. You probably need to assign the debris variable of the _x script in the inspector. Code (CSharp): using UnityEngine; using System.Collections; public class _x : MonoBehaviour { public float speed; public GameObject b; public Vector3 bValues; void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime); } void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "x") { other.gameObject.SetActive(false); } while (false); { Vector3 bPosition = new Vector3 (Random.Range (-bValues.x, bValues.x), Random.Range (-bValues.y, bValues.y), Random.Range (-bValues.z, bValues.z)); Quaternion bRotation = Quaternion.identity; Instantiate (b, bPosition, bRotation); } } }
I guess I should more accurately state, I am trying to get an object to orbit the player. But I am wanting first to collide with object than transform it into an orbit status.