0 Favourites

Throwing with Drag n Drop

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

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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • YES! It works great! Thank you GeometriX.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
84 12,855
WaterlooErik's avatar
WaterlooErik
Unread hot topic
41 2,798
guannstar's avatar
guannstar
Unread hot topic
38 3,722
BarneyGumble44's avatar
BarneyGumble44