The Amazing Retintable Pelican Case - INTERACTIVE 2018-11-08 update with auto-close!
You need to own this item to leave a rating.
BEHOLD! A a box that opens and closes on click — a thoughtful archetype of an everyday essential. But more than that, this exquisitely-crafted PELICAN CASE/CRATE will bring you effervescent joy by demonstrating several Sansar features that you can apply to other objects. Learn from it as an elegant example, and inbue your creations with interactivity!
▓▒░ THE BASICS ░▒▓
At the very simplest, get this item and drop it into your scene.
It open/closes with an accompanying sound when you click on it.
What's more, it uses a neat trick to temporarily disable clicks while mid-open/close.
AND now, it also auto-closes if you leave it alone. And has a collision volume so you don't walk right through it.
You can hide a surprise in this case. Just sayin'. 'Cuz it kind of sucks to open a loot crate and not find anything inside eh...
▓▒░ ADVANCED USAGE ░▒▓
Since this setup is fully permissive, you can re-tint this crate into different color schemes, be they designer pastel swatches or saturated vaporwave, whee! In Scene Objects or Object Structure, right-click the Pelican Case > Materials. (As shown in one of the images on this Store listing.) You'll see you can select various parts of the Case_Outside and Case_Inside (tinting has less of a visible effect), and all you need to do is scroll down, choose a tint to preview, then Save Settings.
Examine the Pelican Case's object structure. You'll notice it has several scripts inside of it, responsible for controlling its behavior as follows:
• SCRIPT 1 - SimpleInteraction - Sends one message on 1st click, another on 2nd so that it toggles between those actions. ALSO notice that Group = case1. Simple Scripts groups make it easier so that a script only sends message to other scripts in the same group. In this case, ALL 5 scripts have "case1". If you make copies of the case, change each new case's messages to "case2", "case3", etc. so clicking a case only makes THAT case work.
• SCRIPT 2 - SimpleAnimation - Plays for the range of 0-120 frames, which corresponds to the case opening/closing. Since this is a symmetrical action, it closes by reversing that range.
• SCRIPT 3 & 4 - SimpleSound - Plays a different sound on open vs. close. If you want to replace these sounds, they're a bit over 3 sec. long.
• SCRIPT 5 - SimpleTimer - This is a handy principle for objects that might get "messed up" or "confused" by clicking repeatedly WHILE they're doing something, like an animation. So what this script is saying, in effect, is: send "case_click_disable" to Disable Interaction (notice the same message used in SCRIPT 1), then at the Interval of 3.5 seconds later when the animation is done, send "case_click_enable" to re-enable interaction.
• SCRIPT 6 - SimpleTimer - Another neat trick. It sends messages to both close the case (case_close) and reset the click sequence (interaction_reset which gets sent to SCRIPT 1's Reset Count) if the case is not touched for Interval = 10 (seconds). You can change this to any other number you want, or just delete this script if you want it to stay open indefinitely. Reset Count is very useful here, because if we didn't reset it, say the case auto-closes and you click it a 2nd time — well that would count as another "case_close" and do JACK SQUAT NOTHING. So you want to reset it so if the case is closed, clicking it once will reliably open it again.
Also notice when examining the object's ANIMATION 1 that it's set to "SinglePlay", does NOT start on load — since it's scripted to animate — and "Playback Speed" has been accelerated to 1.5 its original rate. You can change this (and the sounds to match) to make the case open more gradually or suddenly.
▓▒░ WHAT ARE SIMPLE SCRIPTS? ░▒▓
Glad you asked. They're (as the name implies) an easy way for non-scripters to make their stuff do cool things. To learn more (of course you do):
BTW, don't worry if the above script names show up as "Embedded" when you're viewing Properties. It means the exact version match isn't in your inventory. We may use interim versions that have fixes and updates, and get published publicly later. But for clarity, the script names are called out above.
Now go forth and be awesome!