Question by
JackalSolus · Apr 12, 2020 at 10:49 PM ·
functionvariables
How to update variable from function input
Hi,
I have been trying to understand why the below is not working correctly.
I have a function which takes in a vector 3 from another script.
Everything works fine except "newCamPos = cameraNode;"
The debug.log is pulling through the vector3 i want to update the variable to but no matter what I try it wont update.
any help is much appreciated.
script 1
public void UpdateCameraLocation(Vector3 cameraNode)
{
Debug.Log(cameraNode);
Debug.Log(Vector3.Distance(newCamPos, transform.position));
newCamPos = cameraNode;
}
script 2
void OnTriggerEnter()
{
cameraNode = transform.position
Debug.Log("Entered new zone");
_camera.UpdateCameraLocation(cameraNode);
}
Comment