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.

Newcomers AppGameKit Corner / [SOLVED] Simple 'homing' movement

Author
Message
GH69
User Offline
Joined: 9th Nov 2018
Location:
Posted: 5th Dec 2018 11:59
In my shoot'em up type game I just want to add a homing missle type movement.
I'm sure I managed this in BlitzBasic years ago, but I fear age has addled my brain.
I quickly got to the 'missile points at target and goes straight to it' stage but then wanted to add the smoother movement/rotations rather than sudden changes of direction. I nearly managed it once but it insisted on freaking out on me when it was directly below the target.

I have searched endlessly, finding Unity demos a plenty, a few Java based solutions, mentions of Curveangle(?) in DBP, a very old Blitz code archive demo which I could not get to run. Having spent all yesterday trying to solve this 'simple' thing I ended up on a heap in the sofa reading a Wikipedia article on Slerps, dribbling slightly whilst banging my head against a cushion …

Today I started a fresh with just simple code to get a sprite to follow the mouse pointer


, with the intention of modding that to get the movement I was after, then inserting it into my game. Another half a day and I'm still no closer.


Can anyone point me in the right direction? (no pun intended) I have been trying to pick an angle part way to the angle of the target from the 'chaser' and move towards that, but every way I try just does not work. I fear I am defeated by what should be a simple thing ..

Cheers
Graham

The author of this post has marked a post as an answer.

Go to answer

GH69
User Offline
Joined: 9th Nov 2018
Location:
Posted: 5th Dec 2018 14:40
This post has been marked by the post author as the answer.
Isn't it always the way, as soon as you ask you stumble across a solution.



Very little code, although I don't know how efficient it is, but it's a start.
I'd still be interested in any other methods though.


puzzler2018
User Banned
Posted: 5th Dec 2018 17:25
Yeah - your code looks good and does exactly what it is intended for

Well done. I couldnt have done it any better

Login to post a reply

Server time is: 2019-04-23 19:57:31
Your offset time is: 2019-04-23 19:57:31