Python and move on paths

Hello everyone! I am programming in Cospaces with Python and I am able to program different actions (speech, animations, movements, …), however, I am not able to program an item in order to move on a path.
The code does not show errors, so I have no idea why it doesn’t work.

I define the item as AnimatedItem and the path as a PathItem and then I use the function:

Does anyone know why it doesn’t work?

Thank you very much!

Hi @Silvia,

While many of the parameters are optional in the move_on_path function, a good practice of using functions with multiple optional parameters is via keyword arguments.

In your example you pass path as positional argument, and as such all remaining arguments are expected to be filled. To work around that, you can use keyword arguments.

Below is an example of a path animation defined with a path and speed. Feel free to remix the example as well :slight_smile:

Code used in this Cospace

from cospaces import *
import math
import random

dog = scene.get_item("Dog")
myPath = scene.get_item("Path")
dog.transition.move_on_path(path=myPath, speed=3.0)

Hope this helps!

Hi Stefan, thank you very much for your help! Now my code is working!

1 Like