Tag Info

New answers tagged

0

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 ...


0

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. ...


0

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" ...


1

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 ...


1

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.


0

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 :)


1

I'm gonna make a wild guess that you are using 3D colliders. Check out the colliders of your character and make sure you froze rotation and Z transformation so that your character will not rotate or bounce in Z direction upon a collision.



Top 50 recent answers are included