Unpin then apply force

0 favourites
  • 6 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • Hi all,

    I've been having some issues with the pin behaviour when combined with physics objects.

    I want to simply unpin an object then apply an impulse. You can find a .capx here: https://www.dropbox.com/s/ub8squybwbtwvsl/missile%20pin%20test.capx

    99% of the time the force isn't applied. When adding a wait, of around 0.1 seconds it launches, though becomes unpredictable across different spec devices.

    I've even tried testing for the object not being pinned then applying the force but it makes no difference :(

    Any help would be greatly appreciated.

  • Try putting the unpin action and the physics force action in separate events like this. (Note the boolean to trigger the launch.) I also added an outside layout condition to the the missile. You should probably destroy it (or recycle it) when it goes outside the layout.

    <img src="https://dl.dropbox.com/u/57899112/launchpinnedmissle.PNG" border="0" />

  • Thanks for the reply. The problem with this is that it continues to fire the physics impulse, rather than just doing it once.

    If another system event 'Trigger once' is added, the unpredictability persists.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've updated the .capx here to illustrate my point:

    https://www.dropbox.com/s/ub8squybwbtwvsl/missile%20pin%20test.capx

    This doesn't seem to be related to the bool, but rather the unpinning taking an indeterminable amount of time to actually unpin, despite being registered as unpinned.

  • From the manual:

    The Physics behavior simulates physics separately to the Construct 2 layout. Construct 2 will try to keep the Physics and Construct 2 "worlds" synchronised if one changes but not the other, but this can be unpredictable. For example, setting an object's position or angle will cause Construct 2 to teleport the corresponding object in the physics simulation to the object's new position, which does not always properly take in to account collisions. The same is true of using other Construct 2 behaviors at the same time as Physics.

    Therefore it is highly recommended to control Physics objects entirely via the Physics behavior (by setting forces, impulses, torques etc.), rather than trying to manipulate objects by Set position, Set angle etc.

    It's always unpredictable when you move physics objects without using the physics actions.

    You could use a separate sprite for aiming and then spawn the missile when you're ready to launch. physicsPin.capx (r102)

    Or the other option would be to rotate it with 'set torque' instead of pinning it.

  • Thanks! That makes lots of sense, I don't know why I was determined to unpin a physics object - spawning a new one works great :)

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