This article was written for “UniVCI-0.15.”
https://virtualcast.jp/products/3ece71b9b4213bf2e6a3f6552b6653466e764774ab635bc86678192654a4d1b9
We will be using “onCollisionEnter” as we will be executing the process when objects collide with each other.
Here are the settings for each object.
Set GroupIDs of all SubItem to the same number except 0.
(SubItems with the same number will always have their ownership held by a single user, which is required for proper physics calculation)
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.
AddForce(Vector3) applies a force of Vector3 to a object.
GetUp() gives you the up direction (local Y-direction) in a unit vector.
In this example, the direction toward the tip of the cue is the Y-direction.
function onCollisionEnter(item, hit) if (item=="bili_ball" and hit=="bili_q") or (item=="bili_q" and hit=="bili_ball") then local bili_ball = vci.assets.GetSubItem("bili_ball") local bili_q = vci.assets.GetSubItem("bili_q") bili_ball.AddForce(1000 * bili_q.GetUp()) end end