The example script, Random Movement (RandomMovement.cs), randomly moves a dynamic object around its starting position. Grab it from the download link at the end of this article.
Here is a step-by-step guide to using the script:
- Download the script file from the download link at the end of this article.
- Follow the instructions provided in Working with scripts to upload the script and add it to an object.
- Open the object's Properties panel and go to the Script Settings section.
- On the properties panel, set IsDynamic to On.
- 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.
- 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.
|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.|
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)."