Behavior question
by Robert Hanz · in Torque Game Builder · 10/11/2009 (2:45 am) · 3 replies
So, I've got one behavior that allows an object to take damage and die. I'd like to encapsulate the effect of dying in another behvaior on the same object, so that they can vary independently. However, calling %this.owner.<method> doesn't seem to get delegated to behaviors the same way as calling %arbitraryObject.<method> seems to
So, I could add the code to do what I want to do on death to the behavior directly, but, as I said, I'd prefer not to combine those responsibilities into a single behavior.
Is there any way to do what I'm attempting?
So, I could add the code to do what I want to do on death to the behavior directly, but, as I said, I'd prefer not to combine those responsibilities into a single behavior.
Is there any way to do what I'm attempting?
About the author
Programmer - used to work in game industry. Now, not so much, but it's in the blood.
Recent Threads
#2
If you wanted to get really fancy and have different dying behaviors, you could add a field to your current behavior where you give it the name of the death behavior. Your current behavior would new up the behavior for your "owner" and then it would also have the name for the "getBehavior" call. Just a thought!
10/11/2009 (6:08 am)
To access a behavior of an object, you'll need to use something like the following:%otherBehavior = %this.owner.getBehavior( DyingBehavior );Once you have that, you can call the behavior's functions on "%otherBehavior", like "%otherBehavior.<behaviorMethod>()". I assume this is what you're trying to do.
If you wanted to get really fancy and have different dying behaviors, you could add a field to your current behavior where you give it the name of the death behavior. Your current behavior would new up the behavior for your "owner" and then it would also have the name for the "getBehavior" call. Just a thought!
#3
I'll play with this some more, thanks!
10/11/2009 (4:55 pm)
What I was really hoping for was something more like the Aggregate design pattern, where I could be loosely coupled from the handler of the Behavior.I'll play with this some more, thanks!
Torque Owner Robert Carroll