Stuck on Y Values
![azimpact](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Stuck!
I’m trying to get an actor to be able to jump on another actor to destroy it, but if the other actor hits the first actor from the side, then it’s destroyed instead.
I was able to get the Good Guy actor to jump on the bad guy actor and destroy thanks to Tshirtbooth, but I can’t seem to wrap my head around the math for making the bad guy destroy the good guy when hit from the side.
The good actor is 64 high and the bad guy is 50 high.
To destroy the bad guy, I’ve got the following attribute set:
Game.Player.Y > game.badguys.y +(self.size.height) /1.5621)
My thinking is the Y of Good guy is 32 ( as I understand it, the Y is the center of the actor, perhaps that is where I’m messing up) so if the badguys Y is 25 + (50/1.5621) = 32, then anything above the Y of Good guy will destroy bad guy. This is working
However from the side, when I reverse the formula to apply to the good guy and use the < instead of > the bad buy just passes through the good guy and I can't seem to get the formula to work for that.
Am I correct in understanding that the Y of the actor is the center of the actor?
Any help would be greatly appreciated!
I’m trying to get an actor to be able to jump on another actor to destroy it, but if the other actor hits the first actor from the side, then it’s destroyed instead.
I was able to get the Good Guy actor to jump on the bad guy actor and destroy thanks to Tshirtbooth, but I can’t seem to wrap my head around the math for making the bad guy destroy the good guy when hit from the side.
The good actor is 64 high and the bad guy is 50 high.
To destroy the bad guy, I’ve got the following attribute set:
Game.Player.Y > game.badguys.y +(self.size.height) /1.5621)
My thinking is the Y of Good guy is 32 ( as I understand it, the Y is the center of the actor, perhaps that is where I’m messing up) so if the badguys Y is 25 + (50/1.5621) = 32, then anything above the Y of Good guy will destroy bad guy. This is working
However from the side, when I reverse the formula to apply to the good guy and use the < instead of > the bad buy just passes through the good guy and I can't seem to get the formula to work for that.
Am I correct in understanding that the Y of the actor is the center of the actor?
Any help would be greatly appreciated!
Comments
I would try something like
If player.y < badyguy + (1/2 * player.size.height)
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Thanks!
In CSS, x & y are calculated from the top left. Had me confused.
Using jonmulcahy's example, I ended up with:
game.PlayersY < game.badguysy +(1/2*self.size.height -1)
Works like a champ!!!