Hi! I just trying to send object in a fucntion but it's get null, while value "focus" gets that meaning. What's wrong?
//some code
if (Input.GetMouseButtonDown(0))
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100))
{
Interactable interactable = hit.collider.GetComponent();
if (interactable != null)
{
SetFocus(interactable);
}
}
}
//some code
void SetFocus (Interactable newFocus)
{
focus = newFocus;
motor.FollowTarget(newFocus);
}
So, when I call motor.FollowTarget(newFocus) it's get null exseption, but focus gets value of newFocus (that is GameObject)
↧