- Home /
Variable type - accessible from other scripts on one Prefab.
Hello,
I made a Path-finding/AI script for my enemies. They basically follow my character around when they see him and when something is in they way and i disappear from their FOV they store my last known position in a var "LastSeenWaypoint".
Anyway the problem is that they use multiple scripts and these scripts that are all on the same Prefab/Model exchange variables. So now the Problem is that i wrote and tested everything with only one enemy in my scene. But when i have more then one enemy i cant use static variables anymore because enemies that don't know my location will receive the "LastSeenWaypoint".
So basically i want to know how i can make a variable that can be accessed by different scripts on one Prefab/Model but not by others. I hope I explained my problem good enough.
Thanks for the help in advance.
-Alexander
This is a big problem with over-use of static variables. Sounds like you'll need to rewrite the AI so that each object tracks its own LastSeenWaypoint
.
rutter: can you explain theoretically how i would do this. I guess once I know what to do i can work the scripting out myself.
tanoshimi: but when i don't use static variables i cant access them from different scripts or can I?
thanks for the reply guys.
Your answer
Follow this Question
Related Questions
Global Varible Problem 2 Answers
Accessing another var on another script 1 Answer
Unable to modify a variable in another script 2 Answers