Fighting Game Questions
by Chris Scalabrini · in Torque X 2D · 12/01/2007 (11:35 am) · 6 replies
Hey guys,
I figured I would make a 2d fighting game as a way to familiarize myself with Torque a little bit. Now, that leaves me with a few questions.
First, I plan on having plenty of goofy animations per character (the idea of using a hierarchy of 2D sprite body parts doesn't appeal to me). However, I have been unable to locate the ability to swap between animations thus far in my documentation scouring (although I have been known to miss things in text fairly frequently). I know this capability is included in the TorqueX platformer thingie (and therefore possible), but I don't have 30 bucks to spend. College students need to do groceries. So my question is this: Given a 2d Torque object, how can I change its animation as needed? That includes things like knowing when to change the state and such. For example, the idle animation can cycle, but when the player its the jump button, there's a crouching and jumping animation. At the end, that needs to turn into the "I'm moving up" animation, which shouldn't loop. You get the idea.
Secondly, I plan on attacks having special collision boxes. For example, someone might throw a punch. The 'attack' collision polygon would then collide with the 'victim' hit polygon. However, just before the 'attack' polygon appears, there would be a 'pre-attack' polygon that the victim could then use a 'counter' attack on, which would collide with 'pre-attack.' I have yet to find an easy way to change hit polygons per frame (after all, a punch is damaging when it's flying forward too, not just when it's fully extended). An example of this could be swinging a sword vertically downward. The collision should only happen with the sword, but with one collision box for the whole animation, it would affect a much-too-large area. Any suggestions for getting around this?
That's about it. I apologize if all this information is obvious. I'm assessing several game engines for this project, and I thought I'd give Torque a try after a few of the others I've played with.
-Chris
I figured I would make a 2d fighting game as a way to familiarize myself with Torque a little bit. Now, that leaves me with a few questions.
First, I plan on having plenty of goofy animations per character (the idea of using a hierarchy of 2D sprite body parts doesn't appeal to me). However, I have been unable to locate the ability to swap between animations thus far in my documentation scouring (although I have been known to miss things in text fairly frequently). I know this capability is included in the TorqueX platformer thingie (and therefore possible), but I don't have 30 bucks to spend. College students need to do groceries. So my question is this: Given a 2d Torque object, how can I change its animation as needed? That includes things like knowing when to change the state and such. For example, the idle animation can cycle, but when the player its the jump button, there's a crouching and jumping animation. At the end, that needs to turn into the "I'm moving up" animation, which shouldn't loop. You get the idea.
Secondly, I plan on attacks having special collision boxes. For example, someone might throw a punch. The 'attack' collision polygon would then collide with the 'victim' hit polygon. However, just before the 'attack' polygon appears, there would be a 'pre-attack' polygon that the victim could then use a 'counter' attack on, which would collide with 'pre-attack.' I have yet to find an easy way to change hit polygons per frame (after all, a punch is damaging when it's flying forward too, not just when it's fully extended). An example of this could be swinging a sword vertically downward. The collision should only happen with the sword, but with one collision box for the whole animation, it would affect a much-too-large area. Any suggestions for getting around this?
That's about it. I apologize if all this information is obvious. I'm assessing several game engines for this project, and I thought I'd give Torque a try after a few of the others I've played with.
-Chris
#2
12/01/2007 (1:45 pm)
One thing I considered doing was just having a series of separate templates, one for each frame, and cycling through them manually. However, I'm afraid that would absolutely destroy any semblance of efficiency.
#3
12/01/2007 (2:01 pm)
It would be hard to tell without trying it, but I think you've got the beginnings of something. I probably wouldn't try to swap entire new objects in and out (so you don't have the overhead of constantly creating and destroying objects), but if you just pulled the collision polygons off your templates to match the corresponding frame of the animation you have running normally, that might work.
#4
Since animation sprite sheets are based on NxM Images of the same size, I can assume that all images are the same size. As such, multiple collision polygons could be made with invisible objects of the same size attached to the center of the original sprite.
Since all I need of the new objects are their material and collision polygon, I'm guessing I could add a custom animation component that could load animations from a file (XML probably) that's basically TorqueObject names.
Am I totally off base, or am I heading in the right direction?
12/01/2007 (2:13 pm)
In that case, I think a possible solution would be to keep the one object, but constantly swap out the image and the collision (also somehow include the ability for multiple collision polygons). Here are a few of my ideas:Since animation sprite sheets are based on NxM Images of the same size, I can assume that all images are the same size. As such, multiple collision polygons could be made with invisible objects of the same size attached to the center of the original sprite.
Since all I need of the new objects are their material and collision polygon, I'm guessing I could add a custom animation component that could load animations from a file (XML probably) that's basically TorqueObject names.
Am I totally off base, or am I heading in the right direction?
#5
1. Whenever the animation starts to display a new frame, figure out what cell of the image map is currently being displayed
2. Find the corresponding template object that has the collision polygon set up to match that frame
3. Copy the template's collision poly into the t2dAnimatedSprite's collision component.
On the multiple collision poly's, I'm not sure I'm interpreting you correctly. The Torque X engine actually supports multiple polys on an object (I'm assuming you want this for the concave shapes of your fighters), although the editor doesn't. I would probably do the invisible object overlay thing on the templates in the editor so you could create the polys, but then copy them all in onto the single object in the "animated collision" component.
12/01/2007 (2:35 pm)
I think you're headed in a good direction (I can't guarantee that it's right since I've never done anything like this myself :) ). I'm not sure why you'd want to worry about swapping materials by hand since the t2dAnimatedSprite already has lots of animation support. I think the easiest way would probably be to build the animations the normal way in the editor (instead of having to create your own animation file), and have a component attached to a t2dAnimatedSprite that would do essentially:1. Whenever the animation starts to display a new frame, figure out what cell of the image map is currently being displayed
2. Find the corresponding template object that has the collision polygon set up to match that frame
3. Copy the template's collision poly into the t2dAnimatedSprite's collision component.
On the multiple collision poly's, I'm not sure I'm interpreting you correctly. The Torque X engine actually supports multiple polys on an object (I'm assuming you want this for the concave shapes of your fighters), although the editor doesn't. I would probably do the invisible object overlay thing on the templates in the editor so you could create the polys, but then copy them all in onto the single object in the "animated collision" component.
#6
Each fighter every frame would have a "vulnurability" polygon.
The part of an attack that inflicts damage each frame would have a "to-hit" polygon.
The part of an attack just before the part that inflicts damage (The wind-up to a punch) would have a "pre-hit" polygon.
The part of an attack just after the part that inflicts damage (Recovery from the missed punch) would have a "post-hit" polygon.
A preemptive block would have a "counter" polygon.
A post-attack disabling technique would have a "disable" polygon.
A normal block would have a "block" polygon.
To-Hit would collide with Vulnurability.
Counter could collide with Pre-Hit.
Disable would collide with Post-Hit.
Block would collide with To-Hit.
I also don't want to have to define these things in code, because I want to let my artist design all the various collisions and such, and allow my artist to use the TXB.exe as much as possible.
12/01/2007 (2:59 pm)
Allow me to go into further detail on the multiple polygons.Each fighter every frame would have a "vulnurability" polygon.
The part of an attack that inflicts damage each frame would have a "to-hit" polygon.
The part of an attack just before the part that inflicts damage (The wind-up to a punch) would have a "pre-hit" polygon.
The part of an attack just after the part that inflicts damage (Recovery from the missed punch) would have a "post-hit" polygon.
A preemptive block would have a "counter" polygon.
A post-attack disabling technique would have a "disable" polygon.
A normal block would have a "block" polygon.
To-Hit would collide with Vulnurability.
Counter could collide with Pre-Hit.
Disable would collide with Post-Hit.
Block would collide with To-Hit.
I also don't want to have to define these things in code, because I want to let my artist design all the various collisions and such, and allow my artist to use the TXB.exe as much as possible.
Torque Owner Dan Maruschak
You can enable a callback so that you can have a particular method called whenever an animation frame changes. You should be able to change your collision polygons in that method. I think trying to create the different collision polygons for every frame is going to be tricky, though. Right now the editor assumes that you have a single collision polygon that stays the same forever.