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.

DarkBASIC Professional Discussion / Problem whit traiectories whit dbpro help me!

Author
Message
super philip
17
Years of Service
User Offline
Joined: 31st Jul 2008
Location: Italy
Posted: 10th May 2013 21:34
I\'m sorry, I want to know a way to launch a guided missile dbpro
to the target in a realistic way you can help me? Derek Darkly
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 10th May 2013 22:09
A guided missile, or a heat-seeking missile?

If a guided missile, then wouldn't you just control it with your gamepad or keyboard?

If a heat-seeking type missile, I would use POINT OBJECT as a test (before syncing) to compare the difference between the missile's current path and the desired path. Then simply apply gradual turning towards the desired path based on the missile's turning capability. (Sorry, I don't have any code for this!)

There are much more skilled programmers around here than I, but it's all in the way you ask them.

D.D.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 10th May 2013 22:13
P.S.

(You didn't have to make a duplicate thread, you can edit your old posts anytime.)

D.D.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th May 2013 08:05 Edited at: 11th May 2013 08:08
Quote: "If a heat-seeking type missile, I would use POINT OBJECT "

That wouldn't look realistic. You'd need to curve the angle value and have it gradually rotate towards the target.


M = missle vector
T = target vector
D = T - M (direction vector)

Normalize D, increment speed value by acceleration value, then multiply D by speed and add to missile's position.


An alternative method, using projectile motion that does not have a constant thrust behind, can be learned in my particle tutorial.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th May 2013 23:20
Quote: "You'd need to curve the angle value and have it gradually rotate towards the target."


Yep. If you look at my entire statement, that's basically what I said.
POINT OBJECT could be used (pre-sync) to see what direction the missile should be trying to travel in.

D.D.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th May 2013 12:16 Edited at: 14th May 2013 12:24
Quote: ""You'd need to curve the angle value and have it gradually rotate towards the target.""


I don't want to complicate things, but...
How do you know what direction to turn to?

A guided missile fires outward and needs to turn towards it's target.
Should it turn left or right?

What you need to do is find out what direction has the smallest total turn angle. That way the missle doesn't turn the wrong way making a larger turn then it needs to. Otherwise it looks really dumb.

You do it with a function like this:


Not sure if it'll work for other people without tweaking, if not then it's close.

I had to deal with this when building AI. Same principle the character has to turn to face it's target.

Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 14th May 2013 20:49 Edited at: 14th Dec 2013 17:59
Heat-seeking, with collision detection:



D.D.
super philip
17
Years of Service
User Offline
Joined: 31st Jul 2008
Location: Italy
Posted: 15th May 2013 19:51
thanks a lot for your help guys , it worked.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th May 2013 02:54 Edited at: 17th May 2013 01:44
Quote: "A guided missile fires outward and needs to turn towards it's target.
Should it turn left or right?"


You need to constantly calculate the angle between the missile and target. If the difference between the missile's current angle and the angle it needs to be to hit the target is greater than 180, then turn the missile the other direction.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
super philip
17
Years of Service
User Offline
Joined: 31st Jul 2008
Location: Italy
Posted: 16th May 2013 21:23
thanks Phaelax!
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 17th May 2013 05:51
Quote: "You need to constantly calculate the angle between the missile and target. If the difference between the missile's current angle and the angle it needs to be to hit the target is greater than 180, then turn the missile the other direction."


Yes and you need to account for the 360degree rollover when checking which turn direction has the shortest turn to the target. So it's not just a straight 180 degree measurement. There's a tiny bit more work to do.

Login to post a reply

Server time is: 2026-07-06 18:35:19
Your offset time is: 2026-07-06 18:35:19