Throwing physics objects

  • Hi, I'm very new to Construct and coming from a long history with Flash development it's somewhat of a revelation. I'm still waiting to see the limitations, but so far I've been really impressed.

    I have one problem though and that seems to be that I can't get any of the physics forces working. I'm trying to create a little physics demo that allows you to pick up objects and throw them. I have the physics world set up and the drag and drop element is working, but for the life of me I can't apply any physics force to simulate the throw on mouse release. My current project can be found here: codeandvisual.com/test/construct_physics/physics.capx

    I've set up last_x and last_y variables on the sprite objects so I can monitor the movement between frames, however I've put that to the side for the time being and am just trying to apply a hard coded force of(1000,-1000) - which to my mind would make it go up and to the right when you release the mouse after dragging a sprite. I've similarly tried setting impulses and setting the velocity directly, but nothing seems to produce any sort of movement besides falling straight down due to gravity.

    What am I doing wrong? Eagerly hoping someone can set me on the right path!

  • Well I don't know why sometimes physics behave strangely and seems to be not working, I hope someone can explain us this better.

    Although in your case what you can do that seems to be working fine is set the physics action to be the last one in the event that triggers it and set a wait action before it of about 0,1s. (I changed the apply force to apply impulse and it's working fine)

  • You could use the following events to throw an object:

    <img src="http://dl.dropbox.com/u/22173473/throwpic.png" border="0">

    Here's a capx download

  • I'm also interested in a solution for this. How to make the dragging so it appears that the object is bound to the mouse by a rubber band ? That's how it works by the way in all physics examples i've seen. If you simply apply a force towards mouse it doesn't works since the object flies towards the mouse point than passes it than flies towards it again than passes it and so on. I'm sure there's an easier way to do this. The above example unfortunately doesn't work as expected.

  • You could try this:

    <img src="http://dl.dropbox.com/u/22173473/rubber%20throw.png" border="0">

    capx

    Hope this helps

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks chrisbrobs - by adding in the wait command after mouse release everything started working. Slightly uneasy that you have to do that but obviously there's an explaination based in the physics engine somewhere. This works now, file can be downloaded here by anyone interested.

  • chrisbrobs It gives me an unknown plugin id . Did you use a custom plugin ?

  • chrisbrobs It gives me an unknown plugin id . Did you use a custom plugin ?

    Might be the 'touchmouse' plugin by Rexrainbow?

  • Kiyoshi wrote:

    chrisbrobs It gives me an unknown plugin id . Did you use a custom plugin ?

    Example using the standard mouse:

    capx

  • On a side note, since they were mentioned here, what are plug ins written in and how do you go about making one?

  • jumprock : the plugins and behaviors have their own forum (under "your creations").

    The SDK is the thir stickied topic of "Construct2 general" forum.

  • Example dont work with 94 relase? hmm

  • which plugin this examble used ???

  • Yeah I'd love to try these capx files out as I want to do the same thing with the drag and throw. Anyone have a working capx using the default construct 2 plugins?

  • Try this...Its a bit basic, but it works (R92)

    Drag drop throw

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