Hello and good day everyone!
I have a script that is not attached whatsoever to a game object, that basically somehow (I’m not clear on all the details, apologies) acts on game objects.
What I need to be able to do is find an object that is using that script within the script itself.
To maybe make things more clear, here’s how things are set up.
I have a class called SwingSword, and it, well, swings a sword that’s attached to an enemy. It does not inherit from MonoBehaviour, nor is it ever attached to any game object at any time.
I have the enemy itself, and it can be instantiated throughout the world. Virtually everything on it does inherit from MonoBehaviour (the exception being some non-Monobehavior AI stuff.)
I need to be able to know which game object SwingSword is affecting at any given time so that I can have an instance of certain scripts on the enemy inside SwingSword, thereby only affecting the enemy that needs to be affected, and not all enemies or some random enemy.
If it helps any, this entire scenario was made possible with RAIN AI, and from what I can discern, how it works is that the SwingSword script is accessed through the behavior tree, and that behavior tree is then instanced on an enemy. The behavior tree itself is never attached to a game object, but there is an interface in the inspector that references this behavior tree.
I do hope this makes sense, thanks for your time and have a great day!