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 / Curving trajectory around a body?

Author
Message
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Nov 2021 17:05
Say I have a gun aimed along the tangent of a circle. When it fires at a target (A or B) I want the path of trajectory to curve out from that tangent. Also the targets will not be stationary. I'm not sure if bezier curves are the way to go. I think there's a better type of spline to use in this case but I can't think of what it's called. And I may have written it before back in DBP, but I've lost most of that code in my recent ransomware attack.


Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Nov 2021 17:10
Since nothing is static, I wouldn't go for calculating any kind of curve since it could change every frame.
I would use vector based movement and apply forces accordingly
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Nov 2021 23:00
I think I worked something out. Essentially wrote a curve value routine to interpolate the angle towards the destination. It was a little tricky getting it to rotate either left or right (depending on which rotation was shorter), but a dot product solved that. Only issue I have now is there can be instances where the missile simply cannot hit the target because it can't turn fast enough and ends up just orbiting the target. I don't think this'll be an issue in the long run, we shall see.



Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Nov 2021 08:54
I misunderstood the question. I thought you wanted the bullets to be affected by the gravitational pull of the celestial body
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Nov 2021 14:23
Well that's my fault, I don't think I fully understand what I wanted myself.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-03-29 11:26:10
Your offset time is: 2024-03-29 11:26:10