Physics force not reliable ???

Get help using Construct 2

Post » Sun Apr 01, 2012 3:46 pm

I'm trying to get the physics force to work reliable and its not. The demo i made creates a small blue block when you left click on the brown circle. The blue block then tracks the mouse until you left click again and then a force is applied in the direction of the brown circle. The problem is that it only works sometimes. What could be wrong?

DEMO

Construct 2 Projectrfisher2012-04-01 15:47:32
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Sun Apr 01, 2012 4:22 pm

Fixed capx

Prefer using the "Sprite compare instance variable", it will help you later with picking.

Also as you coded things, the problem was that the force was applied only one tick to the object (since sprite.end is = 1 during only one tick).
In that case prefer using an impulse. Force is to be applied every ticks over time.
Read again the tutorial about advanced physics, all is explained there.Kyatric2012-04-01 16:23:10
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun Apr 01, 2012 6:15 pm

Thanks for the quick reply. I does work better, but still not reacting 100% of the time. I'll still play around with it.
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Sun Apr 01, 2012 7:29 pm

I changed it to apply an impulse of 5 instead of a force of 200 and use Sprite2.X, Sprite2.Y instead of Sprite.sx, Sprite.sy. I also made it shoot when the mouse button is released. Now it works much better.
B
25
S
8
G
8
Posts: 71
Reputation: 5,307

Post » Mon Apr 02, 2012 12:01 am

Still having trouble with impulse being reliable. 1 out of 10 trys finally gets the desired results.

DEMO

Construct 2 Project
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Mon Apr 02, 2012 7:50 am

First, you should give all of the Sprite## objects names. I made some changes to your capx.
Try this.Zephlon2012-04-02 07:52:23
B
25
S
8
G
8
Posts: 71
Reputation: 5,307

Post » Mon Apr 02, 2012 1:13 pm

Thanks for showing me the Chrome Console plugin. I was hoping it would show why it only works sometimes, but i don't know where to look in the functions/code.
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Mon Apr 02, 2012 5:57 pm

I finally have the sling shot working 100% of the time. Later i will post the capx file.

To me it seems that the physics impulse is not being executed (meaning i'm not waiting enough ticks for it to execute.) So all i did was make the impulse condition true until the blue box is overlapping the brown cirle. Once it is overlapping make the impulse condition false.

What i don't know is how many impulses are being executed.

B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Mon Apr 02, 2012 6:00 pm

Oh you were aiming for a slingshot ?
Have you checked this example ?
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Apr 03, 2012 7:19 am

[QUOTE=rfisher]
What i don't know is how many impulses are being executed.
[/QUOTE]
Create a number variable, add one to it after applying impulse, and log it to the Chrome Console. That should tell you how many times it applies impulse.
B
25
S
8
G
8
Posts: 71
Reputation: 5,307

Next

Return to How do I....?

Who is online

Users browsing this forum: Khamsou, nedzad and 11 guests