How do I apply a speed throttle on a physics object?

0 favourites
  • 11 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi everyone,

    So I did this game awhile back using GameSalad.

    Subscribe to Construct videos now

    Do to many of the limitations of GameSalad, I moved over to Construct 2. I wanted to rebuild this game and I made some really good progress except in one area.. the drag speed.

    The physics / drag of C2 is super fast / responsive which in most cases is a great thing. However in this games case it created a lot of problems having boxes pop on the other side of walls. I found that i would often quick which resulted in good throws would sometimes could manage to "pop" through walls that normally should stop an object from going through them.

    What I would like is to figure out a way that an object I drag would follow my finger but generally move slower. If you watch the video you see how the boxes naturally lag behind a little.. and yet when it is time to flick them they still can move faster very naturally. I want to be able to flick something, I just need the box to relax a little! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I had made a number of attempts to find solutions but nothing so far has really hit the nail on the head and effectively simulate the kind of drag behavior you see in the video above. Any insight into this would be much appreciated!

    Thanks

    Caleb

  • Here's how I would do it - at least it's a start...

    Edit to add: it accelerates a sprite towards the mouse position as long as you swipe over it with the left button down (assumes you're going to drag in a straight-ish line) and then slows the sprite to a stop over some sensor objects by setting its velocity.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Colludium that is an interesting way to go about doing it. However that feels a little more like a crane swing it around and while this is not terrible in a simple situation, when you have a bunch of boxes being fed to you i could see that delay making it hard to play the game fast.

    I wonder if there is some way to keep the velocity of the boxes in check to never go above a certain amount? I've made some attempts to do that but nothing seemed to really work. Maybe my understanding of the physics stuff is wrong. I could image that when you let go of the box then the velocity limit might get raised some to allow the box to get flung faster, but still not so fast that it outruns the colliders.

  • OK, I've had a tinker and made a couple of changes. This version sets the selected sprite's velocity towards the mouse (removes the swing effect) and it clamps the sprite's speed between a min and max value (so it appears quicker off the mark and doesn't keep accelerating for as long as you hold the mouse button). Hopefully this will be better...

    Edit to add a reset object velocity variable to zero when it's not being dragged.

  • hey that's nice. I think your throttle works better than my past attempts for sure! Now the only thing I see and I experienced this as well in my own testing.. see how your example box while grabbed but stationary goes kinda nuts?

    it does a kind of double vision effect.. and if you do a tiny bit of movement (even just click a box) it flings off into space.. probably some kind of lower tolerance to prevent that. i just tried a few things and didn't have any luck getting it to not freak out

  • Mmmmm - I'm going to have to think about that. Real work beckons now, unfortunately! I'll take a look later.

  • I totally understand and thank you for your efforts! You still gave me some good ideas to test out as well. I know there is a solution in there it has just been elusive so far!

  • This version sets the sprite's velocity according to its distance from the mouse X/Y - ie, it shouldn't over-swing or oscillate.

  • Colludium dude well done! I applaud your mad skillz. I could never figure out how to tame this oscillating behavior. bravo!

  • Mate, more than happy to help! I enjoy the puzzle solving aspect of game design as much as playing the games....

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