PDA

View Full Version : Combat system help!!!!, need some smart opinions


Lithioq
09-10-2008, 11:00 PM
I am making a beat em up game (side scrolling) but run into one problem.

Is there a way to make it so your hero can only hit the enemy if they are on the same line? I mean in a game where you can go north and south, if you use hitTest, sometimes you can still kick an enemy if your on the top and they are on the bottom. This is especially an issue with larger bosses. It's hard to explain but I hope someone understands what I mean. Think of something similar to castle crashers where if you are on a higher plane you can not smack the enemy. How do I put this system in since I feel it's more accurate and fun.

Thanks for any that help.

syruplord
09-11-2008, 01:03 AM
you'll need to use swapdepth(); to make it so you can go further away/closer to camera. Each guy you have you can make have a movieclip.z property that will show how far away he is. Then you can find the z-distance between you and your target, so you can only hit people in the same line, in other words, if the z-distance is small enough.

Lithioq
09-11-2008, 02:04 AM
The depth part I got down but that z part is confusing. My characters can move up and down the floor. they are just attacking eachother when one is on the top and the other is on the bottom. I can hit my bigger bosses no matter where i am on the floor.

newblack
09-11-2008, 01:23 PM
you're really just sorting depth according to position along the y-axis. you just need to define a margin that enemies must be within to be considered for your collision detection in the first place:

var margin:Number = 40;

//in your collision detection routine
var dy:Number = yourHero.y - someEnemy.y;
if( dy <= margin )
{
//run your hitTests on this enemey
}

rrh
09-11-2008, 05:22 PM
var dy:Number = Math.abs(yourHero.y - someEnemy.y);
And there might be value to storing .z values separately from the .y values because of jumping or if people can climb ontop of things. Lith mentioned "higher plane" so, yeah.

I'd give everyone .ry and .rz attributes, and then update the actual .y according to a placement formula. Like y= ry + rz * 0.3 or something