This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:



Play an animation on grip button press

This article was written for “UniVCI-0.15.”

Example data:

To execute a process when the grip button is pressed, use “onUse”.

In this example, we will create a process that plays an animation
when the grip button is pressed against a certain “VCI SubItem”.

1. Create a new GameObject and create a Cube as its child.

In this example, we named the GameObject “UseAnimation_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 an “Animator” component on the Cube,
Create an “Animation” and associate it with a state in the Animator.
Name the Animation file “UseAnimationAction”.
* Refer to Unity manual for the details of manipulating an Animation.

3. Attach a “VCI Object” component on the GameObject,
and attach the “VCI SubItem” component on the Cube.
When doing this, “RigidBody” components are also attached automatically.
As the Cube won't be using gravity, turn off Use Gravity and turn on Is Kinematic.

4. 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.

function onUse(use)
    if use == "Cube" then
        vci.assets._ALL_PlayAnimationFromName("UseAnimationAction", false)
en/vci/sample/onuse/no3.txt · Last modified: 2019/07/08 17:16 by h-eguchi

Page Tools