====== A fan that spins when grabbed and stops when ungrabbed ====== Let's create a VCI that starts an animation when grabbed using **onGrab(target)**,\\ and stops the animation when ungrabbed using **onUngrab(target)**. === Example data === https://virtualcast.jp/products/f6415cfeabdd56f12b31ceceb4024d2dd7b45d13ddd82f7a7be55a05d09c7e05 ===== Object configuration ===== Each objects are configured as shown below: {{vci:sample:animation:tutorial_fan1.png?400|}} ===== Create an animation ===== We need an animation that turns the fan, so let's create one.\\ Select the root VCI Object (The GameObject with VCI Object component attached). Open the [Animation] tab and select [Create] to create an animation clip. There are several important settings when creating an animation.\\ The **animation won't work** if you forget these settings so be sure to configure them. {{vci:sample:animation:tutorial_fan2.png?400|}} {{vci:sample:animation:tutorial_fan3.png?400|}} {{vci:sample:animation:tutorial_fan4.png?400|}} ===== Component setting ===== Components for each object are as shown below.\\ We don't add anything to the fan and the base. {{vci:sample:animation:tutorial_fan5.png?400|}} {{vci:sample:animation:tutorial_fan6.png?400|}} ===== VCI script ===== function onGrab(target)--When grabbed vci.assets._ALL_PlayAnimationFromName("fan_rotate_anm",true)--Specifying true will loop the animation end function onUngrab(target)--When the hand is released vci.assets._ALL_StopAnimation()--Stops an animation end