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.

Dark GDK / 2D Bullet Tracking

Author
Message
kklouzal
10
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 26th Oct 2012 00:51
With known coordinates of my Target and Shooter I need to fire a Bullet from the Shooter at the Target. I'm doing this in 2d to simplify things, I believe my math is a little wrong though.

I create a sprite at my Shooter, have it rotate to face the target, then move towards it. The bullet gets about half way then starts to spazz out.

kklouzal
10
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 26th Oct 2012 06:47
I've searched the forum on this and can't find anything..

Basically I just need to rotate the sprite towards a set X & Y coordinates.
DeadTomGC
9
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 26th Oct 2012 09:51
You can use dbATAN(Y/x) (any ARC tangent function will do) where y is the distance the point is in the y direction and x is the distance the point is in the x direction from the thing you are rotating.


kklouzal
10
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 26th Oct 2012 17:12
Thank you, I'm getting a little confused can you give me an example?
kklouzal
10
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 26th Oct 2012 22:08
This is what I have so far, it's a little better but the bullets freak out about half way to the target
kklouzal
10
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 27th Oct 2012 20:52
If the target is moving they wiggle like crazy; im confused
darkvee
13
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 27th Oct 2012 23:06 Edited at: 27th Oct 2012 23:08
Just use this.



darkvee

Login to post a reply

Server time is: 2019-09-16 03:41:39
Your offset time is: 2019-09-16 03:41:39