Throwing stuff with the mouses force or velocity

This forum is currently in read-only mode.
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • I need to write a bit of code that lets me grab a platform with the mouse and then throw it with the mouse. Any one have any Ideas on how to do this or example .caps?

    here is the psudocode I am currently using

    Platform Variables needed:







    +On click [platform]:

    -set : startX = mousex

    -set : startY= mousey

    -set :clicked =1


    +On Mouse Hold:

    -set : currentX = Xmouse

    -set : currentY = Ymouse


    +On Mouse Up

    +Clicked = 1

    -X velocity = startX-currentX (//iffy code here, but use these numbers together to get a speed)

    -Y velocity = startY-currentY


    +Every 3 ticks:

    +On Mouse Hold:

    -set : startX = currentX

    -set : startY= currentY

    // so the platform does not go flying if it is held in 1 spot too long....

  • Hope this helps: ... ndtoss.cap

    I had this example lying around from way back when, I just re-made it for the current physics engine.

    There's a bug though, if you let go of the left mouse button while the mouse is outside of the window, the lock-on for the object you picked up isn't reset, so next time you pick up an object it will pick up the previous one along with it. This can be fixed pretty easily though, I just didn't bother.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • worked great thanks a bunch!

  • No problem

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