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 / creating a smooth motion path?

Author
Message
Zeerun
AGK Developer
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: United Kingdom
Posted: 11th Dec 2013 14:38
Hi there,

This one has me scratching my head, I am trying to get a system where you plot out a path, then once finished the sprite will follow the path, I have the fundamentals which I will put up later once I'm at my laptop, but so far once it follows the path it is creating a horrible jagged motion, I am setting the sprite to look at the new marker then move to it, but as they are so close it is not working as I would have liked, but if I reduce the sample of the path points I lose accuracy

Has anyone got any suggestions wherein I can take a series of points and map out a smoothed path my sprite can then follow?

Thanks in advance, I feel my head is going to have to be caved in with lots of math yes?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Dec 2013 15:12 Edited at: 11th Dec 2013 15:17
Yes, you might want some code I have for plotting curves. I'll dig it out.

Here:


oct(31) = dec(25)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Dec 2013 15:21 Edited at: 11th Dec 2013 15:22
Now what I would do is to make the control point where your player starts be positioned in the direction he is travelling / facing and the control point at the other end be in the opposite direction to the way he should be facing at the end.

You might want to look at Bezier curves so you understand the principle behind it. Here is an example of my code in use:


Here the player might start at the top left corner and be facing the green square and wants to end up in the bottom right corner facing away from the blue square (for example)...

Hope that helps!

oct(31) = dec(25)
Zeerun
AGK Developer
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: United Kingdom
Posted: 11th Dec 2013 15:32
oh wow thanks baxslash!

I had found this page just after posting,
http://twistedoakstudios.com/blog/Post3138_mouse-path-smoothing-for-jack-lumber

and was going to translate this into AppGameKit, which I will post up as an alternative, then will try them both out.

Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 16th Dec 2013 14:53 Edited at: 16th Dec 2013 14:53
Hi,

The useful community functions project has several motion path functions pre-built for you.

http://forum.thegamecreators.com/?m=forum_view&t=193433&b=41

Give them a go.

Login to post a reply

Server time is: 2024-11-24 23:22:50
Your offset time is: 2024-11-24 23:22:50