Question

I want to be able to move a node from Point A to Point B by following through a custom bezier path by using applyImpulse method of SKPhysicsBody. The reason I want to use the applyImpulse is because it simulates a nice natural movement (starting fast and slowing down) depending on the initial impulse. It seems that when an object is applied impulse via applyImpulse, it only stops when the friction with environment causes its speed to reduce to zero. I want it to follow my path and stop at the end. How could I go about it?

Was it helpful?

Solution 2

As the posters indicated below, it was not possible to make my object move on custom bezier path after applyImpulse. I used the customActionWithDuration method of SKAction and a custom easing function from https://github.com/warrenm/AHEasing

The effect I wanted is not same or similar to applyImpulse but being able to define my own custom easing function helped a lot.

OTHER TIPS

like LearnCocos2D said, an object following a path isn't currently interacting with applied physics until it's done following said path.

Every SKAction has a property that can be set called timingMode.

so if you instantiate your SKAction on one line, on the next line you can say:

action.timingMode = SKActionTimingEaseOut;

which will start fast and slow down over the course of the action, scaling such that it still completes the movement over the specified duration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top