The example script, Random Movement (RandomMovement.cs), randomly moves a dynamic object around its starting position. Grab it from the Sansar Store or from the download link at the end of the page.
Here is a step-by-step guide to using the script:
- In the My Experiences app, click Edit scene in the scene that you want to add the script to.
- If you already have the file in your inventory, jump to step 3 to start using the script. Otherwise, download the RandomMovement.cs example script at the end of the page and upload the file into your inventory. See Working with scripts for more information.
- Now that you have the script in your inventory, choose an object in the scene that you want to apply the script to.
- Select the Random Movement script file from your Inventory and drag the script onto the object in the scene.
- Now that the script has been applied on the object, open the properties panel for the object. On the properties panel, set IsDynamic to On so that the object can trigger script events.
- At the bottom of the object's properties panel is a Script Settings section. Upon looking at the Script Settings section for the Random Movement script, you will see a list of parameters which you can set for the object. Setting values for these parameters can help you set your object's behavior.
Note: Alternatively, you can also access the Script Settings section from the object's dropdown hierarchy of components on the Scene Objects panel. Right-click on the script component to access the script properties panel. The parameters for Random Movement.
Speed allows you to set the speed of an object. The higher the value, the faster the object moves.
However, keep in mind that the speed is affected by the mass of the object. Make sure that the speed of your object is proportional to its mass.
Chaos Chaos affects how the object changes course when it is hit. The Chaos value should be set between 0.0 and 1.0. The higher it is, the more the object will change course. Range Range determines how far an object will go from their starting position before it goes back to that starting point. Range can be set at any value.
- Once you have finished setting the parameters for your object, your script is ready! Save and build your scene.
- If you want to verify that the script is running correctly, visit your scene once it has finished building.
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: "© 2017 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.
"This work uses content from the Sansar Knowledge Base. © 2017 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)."
Example Script Files: