- Home /
character with multiple areas clickable.. issues
i have a character with multiple animations setup via mechanim. everything controlled via a main script on character fbx prefab. its at same level where 'animator' exists. now i put two spheres (have colliders) on them. put them in heirarchy (head / spine bones etc ) with trasparent shader.
if i put a behvaiour on each sphere, i can detect clicks simply via "OnMouseDown" but its general way of solving.
Q.how to acheive similar behaviour from main script(parent node). i can reference those two spheres in main script at startup. now how to check from main script (on root transform) that one of child transforms sphere (with collider) is clicked. is there direct easy way. i know, this can be solved via raycast or ray hit thing. its not very smart way of doing it. i mean i know exactly two objects which possible can be clicked. i know they have colliders component attached. all i wanted is parent object gets notify (event> on mouse down) on child sphere transform(which has collider)
from my as3 background, i could simply write i.e >> collSph1.addEventListener(MouseEvent.Click, onClickHandler());
huge thanks in advance for time and willingness to share knowledge regards,lala
Answer by lalamax3d · Aug 09, 2013 at 01:18 PM
answer lied in delegates. collider meshes should have a behaviour with delegate variable / function to be used at OnMouseDown. then parent node should reference to that delegate @ startup. if anyonce interested. let me know, i'll post sample scripts here..