Vector3 variable not changing
I can't change the vector3 value for some reason. I initially tried changing it from another script but it wasn't working so I tried this but it still dosent work.
Here's the script containing the Vector3 :-
public Vector3 rotateDir;
public float rotZ = 0;
// Use this for initialization void Start () {
rotateDir = new Vector3(0, 0, 0); } // Update is called once per frame void Update () { }
void OnTriggerEnter2D(Collider2D col)
{
if(col.gameObject.name != "SnakePlayer")
{
col.gameObject.GetComponent<SnakeBody>().rotateSnake(rotateDir);
}
}
public void changeDirVar()
{
rotateDir = new Vector3(0, 0, rotZ);
}
I change the rotZ from another script and then call the changeDirVar function in this function in another script on another gameobject :-
private void makeChangeDir(Vector3 dir)
{
GameObject clone = (GameObject)Instantiate(changeDirPrefab);
SnakeChangeDir a = clone.GetComponent<SnakeChangeDir>();
a.rotZ = dir.z;
a.changeDirVar();
}
Comment