weld objects together upon collision

hi all,

trying to work out how to weld together two objects together upon collision.?

any help would be really appreciated many thanks

(first object is static and second object is moved via linear impulse to try and hit first object)

would the best joint to use be a weld joint? - how would the event listener be written? [import]uid: 10239 topic_id: 4076 reply_id: 304076[/import]

Did you ever get this working?

I am trying to make an object snap to another object when it comes in contact with it.

Specifically I have a pipe with a gap in it and when I drag the missing piece of pipe into place I want it to snap into the gap possibly using weld joints. [import]uid: 44553 topic_id: 4076 reply_id: 64522[/import]

@Crazy Ape Studios why does it have to use joints?
don’t use physics on it, then it will stay still.

you would make the joint like you would make any other joint.
Make the onCollision() point make a joint between the two objects [import]uid: 79135 topic_id: 4076 reply_id: 64531[/import]

Hi, thanks for the reply.

The main pipe in the game is static. I drag the missing piece and its also got a rotate function so that it can be rotated to the right direction at 90 degree rotations depending on the place it needs to fit.

When I move it into place though I need it to join to the static pipe.

From what you suggest above I would have the onCollision() on the piece im moving and when it comes into collision form a joint between two points on it and two points on the static object.

But I would need to also take into account the player might rotate it and try place it incorrectly - I guess I could just have it not snap in place if it is wrong rather than snap anyways and them have to fix their mistake.

If there is another way then it doesnt have to use joints at all, that was just my own way of looking at doing it. If there is an easier better way then I am open to suggestions on that too. [import]uid: 44553 topic_id: 4076 reply_id: 64532[/import]

Hey Crazy Ape, I’m not sure if this can help, but when I want to change how things look & behave, sometimes, I simply swap objects (instead of changing objects). I find it easier than coming up with sophisticated procedures/routines.

So… instead of making the pipe pieces join together properly, how about removing the existing pipes and replacing them with a new set that looks as if the pieces were joined together?

Just an idea, and may not be right for your project, but maybe it can work…?

Naomi [import]uid: 67217 topic_id: 4076 reply_id: 64535[/import]

Hi Naomi, thanks for your reply.

Preferably I would rather be able to use snapping the object in place as it can also then be removed or rotated in place but if I replace the object with an object that represents the completed pipe then I lose that ability.

I can look at doing it that way if I cant manage the other but my preference would still be to have it snapping as its something I could reuse elsewhere in the game.

Thanks for the reply again - any suggestions or options are always welcome and better than none!! [import]uid: 44553 topic_id: 4076 reply_id: 64536[/import]

One way of doing it for you is to create two physics sensors on the ends of the pipes using isSensor and setting the shapes for them using shape=. Then set up a collision listener that detects the hits between the different pipes(or whatever) and runs a function that creates a newJoint or two between the pipes. When you are ready to cut them loose just remove those joints using myJoint:removeSelf()

Cheers

Cell [import]uid: 26289 topic_id: 4076 reply_id: 64775[/import]

I tried this but came across a problem because for collision to be detected the objects had to be a certain body type, this meant the sensor object would fall off. I then made a secondary object which I used to weld it to so that it wouldnt fall but for some reason then the original object was only detecting collision with the object it was welded to and not with any other object.

Any suggestions on this would be great or any other way around it as im still stumped by it.

Cheers [import]uid: 44553 topic_id: 4076 reply_id: 78426[/import]