Hi everyone, thanks for checking this out. I am totally mystified… trying to build an array which keeps the Vector3 position of a game object over time so it can be referenced when a triggering event occurs.
Here’s the relevant code:
using UnityEngine;
using System.Collections;
public class ThrowTrajectory : MonoBehaviour {
public int arraySpaces = 20;
public Transform rightHand;
private Vector3[] rhPos;
void Start () { //THIS WORKS PERFECTLY
Vector3[] rhPos = new Vector3[arraySpaces];
Vector3 v = new Vector3(0,0,0);
//Fill the array with initial vectors
for (int i = 0; i < arraySpaces; i++){
rhPos *= v;*
_ Debug.Log ("rh " + i + " : " + rhPos*);*_
* }*
* }*
* void Update () {*
* Vector3 v = rightHand.position; //This works*
* Debug.Log (v); //This works*
* for (int i = 0; i < arraySpaces; i++){*
_ rhPos = v; //THIS DOESN’T WORK - null reference exception - WHY? It’s the identical syntax to the Start method???
Debug.Log ("rh " + i + " : " + rhPos*);*_
* } *
* }*
}
Any ideas??