Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Impulse from mouse to object

Author
Message
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 13th Feb 2014 04:24 Edited at: 13th Feb 2014 04:30
Say I want to apply an impulse to an object relative to the position of the mouse cursor. For example I click the mouse creating an explosion at the mouse x and y and the object moves away in the proper direction. What should I be using for the last 2 parameters of SetSpritePhysicsImpulse? I have the mouse coords converted to world space for the location of the impulse and am using those for the first 2 parameters but I have no idea what I should be using for the second 2.

EDIT: I basically want to create an impulse from the mouse x, y to my objects x, y
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 13th Feb 2014 10:29
vx=x2-x1
vy=y2-y1

vx=vx * factor
vy=vy * factor

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 13th Feb 2014 23:55
Also, SetSpritePhysicsVelocity() might work better for you

wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 14th Feb 2014 18:58
Thanks guys.

What Markus suggested was exactly what I needed. Thanks!

Login to post a reply

Server time is: 2024-11-25 01:35:21
Your offset time is: 2024-11-25 01:35:21