Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: sebaslive on June 05, 2014, 10:33:26 AM

Title: 2D curved movement
Post by: sebaslive on June 05, 2014, 10:33:26 AM
Hi All, I am trying to make an object go from one vector point to another vector point but I want it to curve to that point.

Like so: (http://www.moshplant.com/direct-or/bezier/curve01.gif)

The two points are going to be random so it can't be a set path. From my understanding on other forums it has to do with bezier curves but I can't find anything like this in the actions...

Code: [Select]
CurveX = (((1-BezierTime)*(1-BezierTime)) * StartPointX) + (2 * BezierTime * (1 - BezierTime) * ControlPointX) + ((BezierTime * BezierTime) * EndPointX);
    CurveY = (((1-BezierTime)*(1-BezierTime)) * StartPointY) + (2 * BezierTime * (1 - BezierTime) * ControlPointY) + ((BezierTime * BezierTime) * EndPointY);
    transform.position = Vector3(CurveX, CurveY, 0);

Any help would be most appreciated!