Per Frame Collision
by Andrew Strauch · in Torque X 2D · 07/25/2009 (1:16 pm) · 2 replies
Hi, I am currently developing a 2D side-scrolling action game that has some melee combat in it. I've been looking for a way to do per frame collision on one of my animated sprites. I want to be able to have a different collision polygon per frame when I tell my character to punch or kick. I did find an older forum post (http://www.garagegames.com/community/forums/viewthread/69907), but I was wondering if there was an established way of doing it, or if anyone could point me to an exact method. Thanks for any help you can provide.
About the author
#2
Brian
07/29/2009 (11:35 am)
@Andrew - I kind of cheated on my game. Don't do this on every tick... I recommend only when you check for a punch or kick. Works VERY well but requires tweaking range to what you are doing. T2DScenegraph.FindObjects().Brian
Torque Owner Matthew Hoesterey
I am currently using a separate hit box object that I manually set to the players position plus an offset each frame.
I am then manually resizing and repositioning the hit box on important frames in my animations.
My game is a fighter so the hit box scaling is a very important part of gameplay and thus I hand tweak it for every attack.
you can do something like
if(AnimatedSprite.CurrentFrame == atkBasic.HitboxResizer1) { _myhitBox.HBOffset = new Vector(OffsetXforAtkbasic, offsetYforAtkBasic); _myhitBox.Size = new Vector(SizeXforAtkbasic, SizeYforAtkBasic); }