Stencyl 3.4.0 is now out. Get it now!

what's the best way to get an actor to follow a bezier curve?


  • *
  • Posts: 509
Any one got a simple way to get  an actor to follow a bezier curve from a list of point?

I've played around with Actuate.motionPath but with no luck - I've looked at other peoples suggestions, but my app doesn't compile, and I get an  "Type not found : MotionPath" error


  • Posts: 1249
Surely there's a pure mathematic solution to this?

What exactly are you trying to achieve? Maybe you can fake it somehow?


  • *
  • Posts: 509
Hi greatanthony, i'd seen that post, but am not sure how to implement it. Were does the public function go?


  • Posts: 132
if all the code logic is understood and only public function is the problem then it should not be hard...

Public function was throwing error b'cause the code is already added to a Event ( or a public function )....

In any event Add the [Code ] block and add the code below to it...
Code: [Select]
tweenLoc.x = getX(false);
tweenLoc.y = getY(false);

if(easing == null)
easing = Linear.easeNone;

var path = new MotionPath().bezier(x, y, checkPointX, checkPointY ,strength);
Actuate.motionPath(tweenLoc, duration, { x:path.x, y:path.y }, false ).ease(easing).onComplete(onTweenPositionComplete);

Put own number inputs in input place like (x , y , strength)  in the code...
Am typing on mobile, sorry for any typo, let know about progress.....


« Last Edit: July 17, 2017, 08:56:35 am by greatanthony »


  • Posts: 1724
Add a custom import in your actor behavior and add this into it:
Code: [Select]
import motion.MotionPath;

After that add the following code in a different event (like a click event or something that's not the Always or Draw event)
Code: [Select]
var path = new MotionPath().bezier (100, 100, 50, 50);
Actuate.motionPath (actor, 2, { x: path.x, y: path.y });

That will make your actor move from it's current position to 100,100 using 50,50 as control points. You can replace those numbers to match your curve points.
The 2 in the second line is the time that the actor will take to reach the target you want.
You can even add a strength to the motion path to tweak how strict the player follows that path should you need to.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • Posts: 132
works great!!  :)


  • *
  • Posts: 509
Thanks SadiQ, the import motion.MotionPath; was the bit i'd missed.