How do I check mouse velocity

Get help using Construct 2

Post » Tue Jul 08, 2014 1:02 am

... and set that to a variable, thanks! I would like to make the effect that if you were to drag an object and "fling" it, it would adopt the speed of the mouse.
B
4
Posts: 5
Reputation: 268

Post » Tue Jul 08, 2014 5:51 am

well i'm not 100% sure if this is what you want to do, but I have a game I'm working on that flings things.

http://part12studios.com/temp/FredexTest2/

so yea if this is what you would like to be able to do... to "throw" something and have it behave with physics.. basically what you want to look at is:

apply physics impulse towards position.

impulse - (distance(Box.X,Box.Y,Touch.X,touch.Y))/10

x - touch.X

y - touch.Y

image point - 0

you'll also want to have drag/drop working as well.. though i rolled my own so I'm not sure if the drag/drop behavior would conflict with it.

good luck!

Caleb
B
59
S
9
G
1
Posts: 970
Reputation: 6,611

Post » Tue Jul 08, 2014 3:13 pm

create 4 variables oldX, oldY, xVel and yVel.

everytick set xVel to abs(Touch.X - oldX), yVel to abs(Touch.Y - oldY), oldX to Touch.X and oldY to Touch.Y.
In that specific order.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Fri Jul 11, 2014 12:06 am

Thanks Guys, I'm testing those out right now!
B
4
Posts: 5
Reputation: 268


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Lancifer, LunaticCat, WesleyDeveloper9 and 7 guests