Throwing with Drag n Drop

0 favourites
  • 4 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • I would like to be able to drag something across the screen using drag-n-drop and when I let go, I would like it to continue going in the same direction at the same velocity. Any example on how this would be done?

    Thank you.

    mypupdaisy

    -- noob and free'b owner until I can make some progress

  • You can do it very easily by using a couple of built-in functions. You'll want to determine its current speed and angle the moment it's dropped. Create an object with the drag and drop and physics behaviours.

    Every tick, you'll record the object's X and Y - this becomes the previous X and Y.

    To determine speed, use the formula of speed = distance / time. Distance is that between the old X/Y and current X/Y. Time is delta time. Distance(previousX, previousY, currentX, currentY)/1*dt.

    To determine the angle you use a similar principle, but using the built-in angle function: Angle(previousX, previousY, currentX, currentY).

    Apply the results to a physics impulse at that speed and angle and you've got yourself a solution.

    Example capx [R117]: here.

    Welcome to the forums!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for the great reply. I will give this a try. Sorry, I can't try the demo you provided. I have the latest version installed and it states that I have R114 and can't load the project files.

  • YES! It works great! Thank you GeometriX.

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