Using BoxCollider2D as prefab
So I experienced problem: when i use box collider 2d prefab as my enemies target point, they just don't target at me.
This variant is working one. I drag active TargetPoint object and my skeleton is targeting normally at me.
Now for prefab, i can't just draw active one, i have to drag prefab object, but when i do it, it just doesn't work, my skeleton doesn't target that position.
That box collider 2d pos is always updating with player position from controllable script, player presses wasd keys, position updates.
For what do you need to use prefab skeleton ? You just can use that working one where you need to drag active targetpoint, you might say. Well, I want to create enemy spawn system, and i need to use prefab ones.
So what i should do to create working skeleton prefab ? I tried storing that targetpos collider in static variable, but that just doesn't update normally, they attack my position before then.
Thanks for answers!
So this is what I can say based on what I think I understood:
There's a player and skeletons in the scene. When you drag the player's targetposition onto the Skeleton's Player slot in the inspector, the skeleton follows the player. But if you choose the player prefab's targetposition as the Skeleton's Player variable value, nothing happens. If that's correct so far, that's why:
A prefab is just a blueprint of something you later want a real (virtual acutally) copy of in your game. With Unity's Instantiate method, you can create such an "instance" which would then be available in the scene like all the other's are that have already been put there.
What you need to do is to use Instantiate for spawning your skeletons. after they've been spawned, you need to assign their player variable the player, or you let them find 'em themselves (GameObject.FindWithTag might be a good choice).
What I don't get though is your screenshots showing different players ins$$anonymous$$d of different enemies.
Your answer
![](https://koobas.hobune.stream/wayback/20220612095529im_/https://answers.unity.com/themes/thub/images/avi.jpg)