|
Have been looking for an easy way get a Component looking the other way than in the children, but there seems to be no easy way? Have I missed somthing in the documentation, or is there only the hard way to do it? (ps. I made up GetComponentInParent, since it was the easiest way to explain my problem)
(comments are locked)
|
|
Try
(where, obviously, "YourComponent" is your component). If you want to search from the top down of your object, you can also get
Both "parent" and "root" are members of the Transform class which you should have access to if your class extends MonoBehaviour. The latter would be a pretty intense operation for frame-by-frame updates, but would suffice for caching in I think I love you!
Aug 31 '10 at 07:53 AM
Tabu
(comments are locked)
|
|
Ok, I feel a bit stupid, but it still might not be the best way to do it. But this is how I did it: I have two scripts, WeaponScript and MovementScript, the WeaponScript is in a childHieracy below the MovementScript. So I start out in the MomentScript finding the WeaponScript, then in the WeaponScript I make a function where I can push the MovementScript. MovementScript takeout:
WeaponScript TakeOut:
I will still absolutely like to hear about alternatives to this way of dooing it, as I am not completly sure this is the best way to do it!
(comments are locked)
|
