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

Get help using Construct 2

Post » Tue Mar 17, 2015 3:00 am

Hi everyone,

So I did this game awhile back using GameSalad. https://www.youtube.com/watch?v=7Cy2qV01B74

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! :)

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
B
59
S
9
G
1
Posts: 970
Reputation: 6,611

Post » Tue Mar 17, 2015 3:30 am

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.
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Tue Mar 17, 2015 5:45 pm

@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.
B
59
S
9
G
1
Posts: 970
Reputation: 6,611

Post » Tue Mar 17, 2015 6:07 pm

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.
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Tue Mar 17, 2015 6:19 pm

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 :)
B
59
S
9
G
1
Posts: 970
Reputation: 6,611

Post » Tue Mar 17, 2015 6:31 pm

Mmmmm - I'm going to have to think about that. Real work beckons now, unfortunately! I'll take a look later.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Tue Mar 17, 2015 7:12 pm

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! :)
B
59
S
9
G
1
Posts: 970
Reputation: 6,611

Post » Tue Mar 17, 2015 9:21 pm

This version sets the sprite's velocity according to its distance from the mouse X/Y - ie, it shouldn't over-swing or oscillate.
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Wed Mar 18, 2015 2:19 pm

@Colludium dude well done! I applaud your mad skillz. I could never figure out how to tame this oscillating behavior. bravo! ;)
B
59
S
9
G
1
Posts: 970
Reputation: 6,611

Post » Wed Mar 18, 2015 2:39 pm

Mate, more than happy to help! I enjoy the puzzle solving aspect of game design as much as playing the games.... :)
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Next

Return to How do I....?

Who is online

Users browsing this forum: draiza and 9 guests