Example Scripts: Mover Examples

There are three mover example scripts to help learn the mover API. Each of them can be set up for use using the standard scripting import and attach process outlined in the following instructions.

Instructions

Here is a step-by-step guide to using the scripts:

  1. Find the MoverExample script files in the Sansar\Client\ScriptApi\Examples folder in your Sansar installation.
  2. Follow the instructions provided in Working with scripts to upload the script and add it to an object.
  3. Open the object's Properties panel.
  4. On the properties panel, set Movable From Script to On.
  5. If the object has a physics, set Motion Type to Keyframed.
  6. At the bottom of the object's properties panel is a Script Settings section. Upon looking at the Script Settings section for the Mover Example script, you can see a list of parameters which you can set for the object. Setting values for these parameters modifies the script’s behavior.
  7. Save, build and run your scene to see the script in action!

MoverExample1

This script makes an object move away from an avatar when they click on it. It shows how to make an object interactive and how to use the Mover API to move an object in a direction. It shows the user feedback in a modal dialog if the object is not configured correctly for movement.

The properties on this script are:

  • Interaction - This is the mouse-over text you see in-world.
  • Distance - The distance the object moves when clicked.
  • Seconds - The length of time (in seconds) for the movement.

The key takeaways from this script are:

  • How to set up an object to be able to move it from script.
  • How to check to see if an object can be moved without triggering an exception.
  • How to translate an object using the Mover API.

MoverExample2

This script makes an object spin on its own. It shows how to use the Mover API to spin the object and wait for the operation to complete.

The properties on this script are:

  • Spin Speed - Spin speed, in number of turns per second.
  • Spin Randomly - ON for random spins, OFF for 360 degree spins back and forth.

The key takeaways from this script are:

  • How to use the mover API to turn an object.
  • How to wait for mover API instructions to complete.
  • Using the different MoveModes together.
  • How to queue multiple operations for a more complex movement with the mover API.
  • Become more familiar with radians and quaternions.

MoverExample3

This script combines the above examples into a single behavior. It shows how to interrupt previous commands queued to the Mover API and replace them with new movement instructions.

It is known as the spinning scared robot script. The idle behavior of the robot is to spin randomly until a player clicks on it, which will cause it to flee away from the player and then go back to idly spinning.

The properties on this script are:

  • Interaction - This is the mouse-over text you see in-world.
  • Flee Distance - The distance the object moves when clicked.
  • Flee Seconds - The length of time (in seconds) for the flee movement.
  • Spin Speed - The speed for idle rotation.

The key takeaways from this script are:

  1. How to combine multiple different movement modes.
  2. How to interrupt and stop previously queued mover commands.
  3. How to check to see if an object currently has pending queued mover commands.
  4. Become more familiar with how to combine current object rotation with new relative rotations.
  5. Become more familiar with how to enable and disable interactivity while performing other commands.

Creative Commons License

This content is licensed under the terms of the Creative Commons Attribution 4.0 International License. When using this content, you must:

  • Acknowledge that the content is from the Sansar Knowledge Base.
  • Include our copyright notice: "© 2019 Linden Research, Inc."
  • Indicate that the content is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.
  • Include the URL for, or link to, the license summary at https://creativecommons.org/licenses/by-sa/4.0/deed.hi (and, if possible, to the complete license terms at https://creativecommons.org/licenses/by-sa/4.0/legalcode.
    • For example:
      "This work uses content from the Sansar Knowledge Base. © 2019 Linden Research, Inc. Licensed under the Creative Commons Attribution 4.0 International License (license summary available at https://creativecommons.org/licenses/by/4.0/ and complete license terms available at https://creativecommons.org/licenses/by/4.0/legalcode)."

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.