This article was written for “UniVCI-0.15.”
https://virtualcast.jp/products/ca1869495cfba094ed5b492511c2a7115893617c33ed655f0d103fce8f448c98
To run a process continually while a VCI is present, use “update” function.
For the rotary movement, use Quaternion.AngleAxis to make the object rotate around the specified axis.
In this example, use GetUp() function to make the rotation around Y-axis.
Reference: Quaternion.AngleAxis
https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Quaternion.AngleAxis.html
1. Create a new GameObject and create a Cube as its child.
In this example, we named the GameObject “Rotation_VCI”, but it can be anything really.
Let's name the Cube “Cube.” Specify Y-axis value of the Cube to 1 so that it doesn't go through the floor.
2. Attach the “VCI Object” component on the GameObject,
and attach the “VCI SubItem” component on the Cube.
When doing this, a “RigidBody” component is also attached automatically.
As we won't be using gravity, turn off Use Gravity and turn on Is Kinematic.
3. On the VCI Object component in the GameObject, set the Scripts Size as 1.
Enter “main.lua” in the Name and paste the script shown below.
local cube = vci.assets.GetTransform("Cube") --Insert the name of the SubItem as a string local rotSpeed = 1 --Rotation speed function updateAll() if cube.IsMine then -- Called only when you have the ownership of the cube cube.SetLocalRotation(Quaternion.AngleAxis( rotSpeed, cube.GetUp() ) * cube.GetLocalRotation()) end end
For details of each component settings, see the image below.