New answers tagged platformer
Found an easy solution to the problem. I just compared the midpoint x-coordinate of the player to the x-coordinate of the intersection to see where the player was relative to the platform (i.e. left or right). If the x midpoint of the player's rectangle > x point of intersection rectangle, then he should be on top - otherwise, he's on the side of the ...
Yes, there is a trick you can use here. Based off of your glitch and your code sample, I'm assuming that you're moving both the player's X and Y position at the same time, then checking for collision. Instead, move the player by its X velocity, then check for collision. If it has collided with any platform, then it must have hit the side of a platform. ...
After a few years of research, game programming, trial and error, I've come back to answer my own question. I've found that the best way is to do this is using the Artemis Entity Component system. For those interested, research in component based architecture. It changed my life (for the better). Create a Collision Component and attach it to the "Player" ...
I haven't used unity, but most likely your terrain is using a different collision type, such as static terrain. Unity is probably finding the correct contact point for these, whereas for two dynamic collision boxes (player, monster) it isn't trying so hard to keep them from overlapping since you're likely to implement some sort of damaging mechanic. You ...
Another solution would be to add another collisionbox ontop of the enemy that is onTrigger, when it's triggered push the player up a bit and destroy the enemy.
Use Physics2D.Raycast http://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html on your enemies and then check if your player hits the enemies raycast that's on top of the enemy. Cheers, Demetry :)
Top 50 recent answers are included