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.

2D All the way! / Move Object to Player (from any position)

Author
Message
Crabbages
12
Years of Service
User Offline
Joined: 12th Aug 2010
Location:
Posted: 22nd Mar 2011 23:46
Hello everyone.
Soooo the player would be in the centre of the screen and the object (which could spawn anywhere) will travel to the player and allways at a certain speed nomatter the distance.

I feel like I keep coming close but slipping up along the way...is there an answer? I bet it's staring me in the face.
(atm im looking into trigonometry with sin and cos but good grief my brain hurts.)

Thanks for loooking.
Hodgey
13
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 23rd Mar 2011 12:19
Hi, here is a 2D example, hope it is what you're looking for. If you're looking for a 3d version, I don't have time to write one up right now but maybe on the weekend.



A clever person solves a problem, a wise person avoids it - Albert Einstein
Crabbages
12
Years of Service
User Offline
Joined: 12th Aug 2010
Location:
Posted: 23rd Mar 2011 18:26
Brilliant! Thankyou very much.
You could do a 3D version to help other people and the future me, I had done alot of searching and don't remember a 3d version I just remember a mountain of 404 pages but this alone was wonderful.
I always feel terrible that I only ever ask for help and can't give any...someday.. I should sit down with this and conquer my old enemy trigonometry.

Thank you again
kamac
12
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 23rd Mar 2011 21:32
( By the way, wrong thread , next time post it here or here )

Hodgey
13
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 23rd Mar 2011 22:25
Glad it helped. Just realized that the sin and cos functions aren't necessary so to save you a bit of grief here is the same example without the sin and cos which works just as well.



A clever person solves a problem, a wise person avoids it - Albert Einstein

Login to post a reply

Server time is: 2022-12-05 03:41:35
Your offset time is: 2022-12-05 03:41:35