• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Good top-down character collision code

Hey, does anyone know a way to make player's units not get stuck in objects in a top-down (RTS) game. I've tried altering sprite masks, and using some collision codes i used back in Gm7 - 8, but to pretty poor results. What ways are there to make units smoothly move around, avoiding obstacles? Or a good collision code?
 

flerpyderp

Member
Are you using image_angle to change the direction the sprite is facing? Doing this will also rotate the mask, meaning it is possible for it to get stuck in objects. If this is what is happening, the solution would be to make a variable to store the direction. Use the function draw_sprite_ext in the draw event, and enter the new variable you created for the argument "rot". Now use this variable instead of image_angle.
 
Are you using image_angle to change the direction the sprite is facing? Doing this will also rotate the mask, meaning it is possible for it to get stuck in objects. If this is what is happening, the solution would be to make a variable to store the direction. Use the function draw_sprite_ext in the draw event, and enter the new variable you created for the argument "rot". Now use this variable instead of image_angle.
Ah, never thought of this. I do use image_angle, and I rarely draw my sprites separately in Draw, although nowadays more. Thanks for reply, I'll try this one out
 

Gamerev147

Member
Do you also have problems with the gun of your player poking through walls? If so, I've spent a long ass time coding PERFECT top down collision code.
I can share it with you if you'd like. However, it's a lot of code and you'll have to really understand what is happening in the code if you wish to alter it.
 
Do you also have problems with the gun of your player poking through walls? If so, I've spent a long ass time coding PERFECT top down collision code.
I can share it with you if you'd like. However, it's a lot of code and you'll have to really understand what is happening in the code if you wish to alter it.
I'm open to try anything! It's an RPG where i have problems with enemies and player's objects colliding smoothly; when they confront they don't just stop to attack each other from the directions they came, but start circling each other uncontrollably to try and find the right position. It's tedious... but yea even a bigger code, i'm willing to try
 

Gamerev147

Member
I'm open to try anything! It's an RPG where i have problems with enemies and player's objects colliding smoothly; when they confront they don't just stop to attack each other from the directions they came, but start circling each other uncontrollably to try and find the right position. It's tedious... but yea even a bigger code, i'm willing to try
Well in that case I'm not sure mine will work, as for it's between the player and any static (and solid) level objects.
 
Well in that case I'm not sure mine will work, as for it's between the player and any static (and solid) level objects.
yeah, this is more about moving objects actually stopping to fight one another correctly and not spending eternity finding the right position to stop still... but i've got some codes to test, lets see. thanks anyways tho
 
Top