Game Development Community

Behavior Inheritance and derivative

by Eyaly · in Torque Game Builder · 07/15/2008 (3:21 am) · 2 replies

Hi
i wonder how can i derive/inherit behavior to a new behavior.
lets say i have 2 behaviors
one named B_SHOOT
and the second behavior named B_MOVE
now i want to create third behavior name: B_SHOOTWHILEMOVE
which derive from B_SHOOT and B_MOVE.

1. how to implement this?
2. does B_SHOOTWHILEMOVE will appear in TGB interface with B_MOVE and B_SHOOT attributes?

thanks

#1
07/15/2008 (10:54 am)
Hmm, I think the idea would be to have B_MOVE and B_SHOOT just naturally work together if on the same object so you don't need a 3rd combined behavior.

But lets say you wanted to make a new behavior that contained some aspects of B_SHOOT, some of B_MOVE, and some of its own...

Well you could either decompose B_SHOOT and B_MOVE into smaller sub-behaviors so you can add only the parts you want to the object, or you could just copy and paste the parts you want into a new behavior.

I think option two makes more sense with behaviors as simple as these.
#2
08/17/2008 (6:02 am)
I know this is old but I just found it. I think the way to go with creation of game objects is composition as much as possible, and behaviors support this. Generally speaking, inheritance ties you into a hierarchy that can become difficult to manage, maintain and change at a later date. Behaviors naturally direct the developer towards using components for object creation.