Hello,
I’m wondering how I can call my humanoid’s MatchTarget() function from another script.
I need to pass in some parameters like “Vector3 targetPosition” from my interactable object.
However, if I use something like the following code in my object script, it doesn’t seem to register/work at all:
playerScript.MatchTarget(aimTarget.position, targetPosition);
Do I have to just set the player’s target transforms within my object script instead of calling the actual function?
Thanks!
What does that mean, exactly?
Do you have any errors in your console? How do you get "playerScript"s value?
StarManta:
What does that mean, exactly?
Do you have any errors in your console? How do you get "playerScript"s value?
Apologies, didn’t mean for that to be vague!
playerScript is initialized before Start then defined in the Start() method:
playerScript = player.GetComponent<Interacting>();
Then I have void MatchTarget(Vector3 aimTarget, Vector3 targetPosition){ } in the Interacting script.
No console errors, it just doesn’t seem to have any effect vs not having it at all.
Have you tried putting a Debug.Log() statement in your MatchTarget method to see if it is running at all?
You will get a big hint about what is going wrong by sprinkling your code with Debug.Log() statements to see what’s running and what isn’t.
1 Like
PraetorBlue:
Have you tried putting a Debug.Log() statement in your MatchTarget method to see if it is running at all?
You will get a big hint about what is going wrong by sprinkling your code with Debug.Log() statements to see what’s running and what isn’t.
Hi Praetor, easy to forget for some reason but always a great tip. This really allowed me to wrap my head around it. Thanks