How to destroy a physics distance joint?

Get help using Construct 2

Post » Thu Jan 12, 2012 8:47 pm

I used the Physics distance joint action. Is it possible to destroy it?
B
228
S
6
G
8
Posts: 86
Reputation: 12,295

Post » Thu Jan 12, 2012 8:53 pm

Can you not just use the destroy action? surely that would automatically remove it?

Or i guess you want to remove it at runtime?

If so try adding a variable called attached.

System.OnStartOfLayout
     ->System.setValue{sttached(1)}

Then make your joint:
- note were adding another start of layout event;
system.onStartOfLayout
system.comapareVariable{attached = 1}
     -> create distance joint{object1, object2}

Then on some random event:
Object1.obcollisionWith{SuperDancingRabbitChild}
     ->System.setValue{attached(0)}

hopefully that works
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Thu Jan 12, 2012 8:54 pm

I have not actually tested this, just wrote it out of my head so let me know. But i doubt it will work unless there is a system.EveryTick event.

Gimme ten mins and i'll try figure it out and provide a capx. Im just writing a tutorial for another user..
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Thu Jan 12, 2012 8:59 pm

Yes, it is on runtime.

What I need:

On any click:
> Create physics joint from Object1 to Object 2

On button released
> Destroy physics joint

It would allow me to click again in another point and create another physics joint
B
228
S
6
G
8
Posts: 86
Reputation: 12,295

Post » Thu Jan 12, 2012 9:09 pm

If you need to constantly do it then why not consider another method?

Like having a sprite that can act as a joint?

Take a look at this post -

http://www.scirra.com/forum/platformer-the-hookshot-with-mouse-button_topic45811_post286717.htmlsmitchell2012-01-12 21:10:46
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Thu Jan 12, 2012 9:16 pm

Is this the only way to do this?

Once a physics distance joint created, can never be destroyed?
B
228
S
6
G
8
Posts: 86
Reputation: 12,295

Post » Thu Jan 12, 2012 9:58 pm

There is no event i know of.. But try the destroy thing i spoke of above
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Thu Jan 12, 2012 10:15 pm

It sounds to be an option. But I have to spawn the object again. I am going to try that.
B
228
S
6
G
8
Posts: 86
Reputation: 12,295

Post » Wed Mar 14, 2012 10:18 pm

@Jailson Did you ever have any luck with this? I'm also trying to destroy a distance joint at run-time.
B
20
S
5
G
3
Posts: 65
Reputation: 3,764

Post » Thu Mar 15, 2012 11:18 am

The way i did it, was to kill (destroy) one of the holders of the joint and create new object (system) the same object or sprite as the one just killed at the exact same position and angle.

This works great with like a pendulum effect. There i kill the static image by clicking at it and create a new one at the exact same position. This make it seem like if i click the object (sprite) i destroy the joint.

Cheers !!
B
12
S
2
G
5
Posts: 31
Reputation: 3,494

Next

Return to How do I....?

Who is online

Users browsing this forum: cesisco and 10 guests