Physics force not reliable ???

0 favourites
  • 10 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • 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 Project

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

  • Thanks for the quick reply. I does work better, but still not reacting 100% of the time. I'll still play around with it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

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

    DEMO

    Construct 2 Project

  • First, you should give all of the Sprite## objects names. I made some changes to your capx.

    Try this.

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

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

  • Oh you were aiming for a slingshot ?

    Have you checked this example ?

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

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)