• 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!

How to find the angle of nearest point where the object is not colliding with other object?

E

Edwin

Guest
Hello, people. How to find the angle of the nearest point where object will not collide other object like in Super Mario Maker, where if you put player inside the block, he will be pushed away from it. How to perform it?

For example, if the first object spawns in the same place as second object spawned then I need to push it to the nearest point where it will not collide.
 
Last edited:

NightFrost

Member
If objects are roughly spherical or square in shape, a good bet is the nearest point is in the same direction as the center of pushed object is from the center of object that is pushing. Then you just have the pushed object keep checking: if colliding - move further away. But it will be a problem if there are other objects in the way... Either they need to get pushed too or you have to look for clear space before selecting push direction. Of course if you have moving objects the clear space might no longer be, when the pushed object gets there.
 
Top