Is there a Grab and FLING or Toss behavior?

0 favourites
  • 13 posts
From the Asset Store
Paper Toss 3D
$7.50 USD
50% off
Template for a paper toss model with 3D aspect (illusion)
  • Greetings,

    I'm creating a physics based game and wanted to be able to grab an object, then upon release - have the object go forth with momentum based on my drag motion.

    I know there is a Grab and Drop behavior, but it just drops upon release - with no momentum.

    Any way to do this?

    Thanks for any help or input..

  • Try something like this

    var disc.touchid = -1

    var force = 200 // tinker with this to get it to feel right

    onTouch disc

    set disc.touchid = touch.touchid

    isTouching

    disc.touchid >= 0

    --> disc force=distance(discxy, touchxyforid(disc.touchid))*force, disc angle = angle(discxy, touch.xyforid(disc.touchid))

    onAnyEndTouch

    disc.touchid = touch.touchid

    --> disc.touchid = -1

  • Thanks but I'm relatively new to Construct..

    What is disc.touchid? Where and how to change? What is var? declaring variable?

    I understand the very basics of Events Behaviors Actions.. I understand that 'isTouching' is a behavior and know where to find that. Same with 'onAnyEndTouch'..

    But everything else is vague to me as to what you are doing. 'var disc.touchid' 'var force' where to set this?

    Sorry for being a noob =} Thanks for the help , I do appreciate it

  • It's funny how often this topic comes up. Here's an example that I made a while ago for someone else: example capx.

  • I wrote it like this:

    On object click, lerp or set the X and Y to the mouse.

    Store the current velocityX and Y of the physics object while it's being dragged.

    On mouse release, set the objects new velocity x and velocity y to the variables you stored.

  • GeometriX

    Hey, that's a great example ! But there are two problems :

    • the balls goes through the green walls when speed is high and well as when it is dragged.

    Is there a way to correct that ?

  • I was using another program, where I was encountering the same issues with balls clipping through collisions at seemingly random times.. but also notice when it was going at a faster speed , more specifically - a movable object colliding with a non-movable object, would clip. That's why I tried to use this program - but maybe these drag and drop interfaces are too basic to prevent such intricate detections.

    I will experiment more tonight, thanks all for the input. I didn't know this came up so often - I did a search and couldn't find much on the toss/fling stuff..

  • Laurent, I'd suggest adding an event on ball collision with the wall, drop the drag and drop, and set the ball physics bullet property to true.

  • Thanks everybody for the input.

    The community here really is helpful unlike some others that I have experienced.

    Cheers.

  • I have the free version of Construct 2 so it only publishes to HTML5.

    But I noticed - everything works great except after the first few seconds when I Preview it in browser (Firefox) - the scene 'freezes' for a few seconds then resumes perfectly. From then on out, it doesn't freeze and everything runs smooth until I close session. Is this an issue that is caused by code or just because I'm in free version previewing in browser?

    <img src="smileys/smiley5.gif" border="0" align="middle" />

  • I don't have the same issue (although I use Chrome), and I've shared this file a few times in the past and nobody else has reported as such, so it's possibly just your machine. Does it do this with other projects? Can you try another web browser and see if it does the same thing?

  • Can you do that same game but without gravity?,i'm trying to do something like that but in a view from the top and coliding with another balls/disc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • TestaDiDrago

    You can turn Gravity on and off, it is in the "Physics Global settings" for an object (but applies to all objects that use physics).

    So, at start of layout, choose an object that has physics, and set world gravity to off.

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