Path follow

Hi all,

In my app I allow the player to draw a path on the screen.
I simply plot sprite at the x y to show the route.
Once they finish I intend a boomerang to follow the path.
Problem is due to human nature the actual path is choppy and wobbly as it’s dependant and where they placed their finger.
Is there a method or better way to ‘smooth out’ this rough path; or perhaps a completely different method that produces a more refined result?

Cheers

I assume you’re using the x/y position every frame. Instead of that, you could sample the x/y position only occasionally, like every .25 second or so, and plot a catmull-rom spline through the sampled points.

–Eric

Hey Eric5h5,

I did think a spline of sorts. But how an earth do I generate such a thing???. I guess I was being rather too optimistic so think itween had a nice function to achieve this :-))))))

Any ideas! - Happy New Year BTW!

Cheers

Found some stuff on Wiki; will give it a try!; not nice Maths to do in 2011 but who knows for 2012!!! :-))))

Cheers

Edit:

I see in itween : iTween.PutOnPath
Presumably I can (as you suggest) just sample the ‘drawn’ data every so often and add a node. Then get itween to build the path and away I go!!. I do have one issue though. Suppose the boomerang hits an object during it’s predetermined path. I may need to (for example) bounce off that object and then ‘get back’ to the original path at some point. Not sure how messy/complicated this could become :-)))

Cheers

Well,

Had some luck - but still not right. Using the waypoint example; problem is my points are not equal distance apart so animation is choppy at any higher rate than 1 :-((

Cheers