Scripting it all together: Follow that path Lizardman

Hello everybody,

Today I will show you how to mix a Task, an avatar and a path together to get an avatar follow a path.

This only works in Beta 5.1 and upwards!

First of all I am starting in Lost Isle 3, look at this image:

There is one Lizardman in front, his name is PlayerAvatar, we will make him follow the Path you can see in the picture too, and that path is called path1.

So, how does all the magic work? Using scripting.

So first of all drop an instance of PythonTaskScript from Asset Explorer into Scene view. You can find your new Task now under World Explorer/Tasks/Base Types/Task0. Now double click it and under Event select Scene Load.

We need the Navigate command to make our lizardman follow the path. The command looks like this:

Navigate("self", "path", "mode")

Note you can also find this when right clicking in the code view and selecting code snippets. 

Where "self" is the entity, "path" is the PathObject and "mode" is the mode.

There are three modes:

Think of three path nodes, 1, 2 and 3.

  • Once: 1,2,3
  • Looped: 1,2,3,1,2,3,1,2,3,1,2,3...
  • PingPong: 1,2,3,2,1,2,3,2,1,2,3...

For now in our Tasks code view we will add:

Navigate("PlayerCharacter", "path1", "Looped")

This will make our avatar always follow the path. Enter "Run" mode and click the Execute button in the task editor. You can now see how your avatar follows the path. (Note: This only works either when clicking execute or since this is an execute event, when the scene is reloaded.)

If you have any questions or feedback do not hesitate to post it.

-Chris


love