The example script, Cannonball (CannonGameExample.cs), throws a cannonball from the avatar. You can get the script file from the download link at the end of the page or in the client directory: Program Files > Sansar > Client > Script API > Examples.
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.
- With the CannonGameExample script selected on the dropdown menu, the parameters listed in the Script Settings shows it's associate public parameters. Fill out the parameter fields based on the script's parameters as defined in this article under Script Parameters.
- 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 the scene and trigger the script by using the trigger buttons listed in this article under Script Controls.
Sets the speed at which the cannonball is thrown. The higher the value, the faster the object moves. If InitialSpeed is lower than 1.0 or greater than 200.0, then the speed defaults to 10.0.
Sets a delay on throwing the cannonball. The number entered represents the number of seconds between each throw.
Note: If a user repeatedly presses the throw button, the number of throws accumulate and will fire in succession while still considering the delay time.
|Fire Sound||Assigns a sound to play when the cannon is fired.|
|Hit Sound||Assigns a sound to play when the cannon hits a target.|
|Loudness||Sets the loudness of the Fire Sound and Hit Sound when played.|
|Spawn Point 1||
Sets teleport points. If Spawn Point values are entered, the targets that are hit randomly teleport to the designated spawn points.
Currently, you must set position points on all four points. By default, the position points <X,Y,Z> is set to <0,0,0>. Leaving <0,0,0> as a position point for any spawn point may teleport the target to <0,0,0>. You may enter the same position point values across all spawn points if you don't want the target to teleport to the <0,0,0> position point.
|Spawn Point 2|
|Spawn Point 3|
|Spawn Point 4|
Use the following buttons to trigger the cannonball:
|Oculus touch controllers||X button|
|Xbox controller||A button|
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)."