Within Distance Dont React on Prefab

Nikita

New member
Hi. )

Within Distance works with object that was in scene before play -but if i create Clone of it it dont work.


1 First red sphere was in scene from start and knights react and work as i want

2 i press button to create the same sphere from prefab and knights dont react on it



unity 2018.2.02
BHD -1.6.1




knights.gif
this behavior on each knight -if enemy with tag "Soldier" within distance start atack -if not stop atack

it is screen of working good behavior.
Screenshot_99.jpg

not working- the same just dont trigger when sphere close
Screenshot_100.jpg
 
Last edited:
bh on each knight
Screenshot_102.jpg

strange thing if i dont delete started sphere and let react on it secont time -knights unfreezes and start react on prefab.

cant catch where the mistake, maybe its Unity issue with prefabs or smthknights2.gif
 
Last edited:
Ye - the only thing i dont have target objects from start i find them by tag
Screenshot_109.jpg
maybe im wrong but as i understood from "within distance" script ONstart() it find objects with tag and then add them to list... if i create a prefab its not in list and thats why "within distance" dont see it . Screenshot_104.jpg
i will try to update "within distance" or gameobj list variable each time i create prefab.
 
Last edited:
oh for somebody who will meet the same issue

i avoided this just by using layers and physiks2d instead of tags -layers work with prefabs as expected becouse update list on collision
ty Justin for help and great plugin
my problem solved at this moment)
Screenshot_110.jpg
 
Last edited:
Top