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

Best way to join physics objects together on collision?

S

SBLux

Guest
My 2D game involves firing projectiles at towers made from blocks to knock them over. I want to make a sticky-bomb type projectile. So basically I want the projectile to stick to whichever block it hits at the point of collision.

All the objects are physics objects and the room is a physics room. What is the best way to achieve this? Any help would be much appreciated!

game.png
 

Bart

WiseBart
Using a weld joint to connect the two physics instances may be an option.

Another thing you could do is destroy the projectile instance and bind an additional fixture (one with the same shape and dimensions as the projectile instance's fixture) to the block instance, offset by its relative position. You should be able to use physics_fixture_bind_ext for that.
It has a disadvantage, though, since you need the projectile's fixture. And as far as I know, there's currently no way to get a physics object's fixture (the one that you define in the object editor).
 
Top