A simple tutorial to setup an interactive test.
If you expand on the example here, you can build up a whole learning game. This simple setup is the foundation for some fun interactions.
THE BURGER TEST:
1) Draw the scene
Remember:
- You will always right click or hit esc key to 'exit drawing' after you draw/place anything into the space from the toolbox. This resets your interface to the transform tools so you can select, position and scale the items in your space.
- You can always undo steps with ctrl + z or edit>undo.
Import a model from Google Poly:
- https://poly.google.com/
- Browse to find a simple object: here's what we'll use
- Download (OBJ)
- Save it somewhere you'll remember
- In Simmetri: file > import(Optimized) > (select your file)
WOAH !!! That's too big...
Let's Resize and Position the model:
- Toolbox > transform(top list) > scale(bottom list)
- Scale your model down (have it look like that below)
- Position it to the left: toolbox > tranform (top list) > move (bottom list)
- Select the bottom part of transform widget.
Make the model "Physical":
This will allow it to fall, roll, collide and be 'grabbable' in present time. Technically what you are doing is giving this model what's called a "rigidBody" -- a way Simmetri can simulate physics on it (like gravity and collisions). Entities drawn IN Simmetri are almost always physical (have a rigidBody attribute). Anything Imported from OUTSIDE you will need to 'make physical'.
- Toolbox > Physics (top) > Make Physical (bottom)
- Select the model (hamburger).
- Its now 'physical'. Press play and try throwing the burger... see the burger fall and bounce. there you go.
Draw a Sphere:
- toolbox > entities (top) > sphere (bottom)
- Draw it on the right side
- Right Click to exit drawing.
Draw a Ring - Using "Tube":
- toolbox > entities (top) > tube (bottom)
- Draw it in the center of the space directly between the sphere and the model (hamburger)
- Right Click to exit drawing.
Make the ring/"tube" Not-Movable:
We want this tube to stay put when things collide with it. They will roll right over without disturbing it. Note: the tube is a Simmetri Entity and is movable and physical by default. It will collide, but it will move.
- Select the tube in the space
- Open Property Editor
- Select RigidBody (left) > Movable (right) > set to "false
Draw a Trigger:
Triggers are like buttons in space; when things enter and exit they fire an event and run a script. You write that script to tell Simmetri what to do when something enters:
- Toolbox > trigger (top) > sphere
- Draw it directly in the center of the tube. The start point should not be touching the tube it should touch the ground. 1st next photo.
- The trigger should be a little bigger than tube. 2nd next photo.
Where to start the trigger drawing: Start the Trigger in the center of the tube (inside the ring touching the ground): keep holding left click through this step.
Expand the trigger to be a little bigger than the tube itself.
2) Setup interactions
Make sphere and model (Hamburger) Grabbable:
Present-mode is the way your experience will be deployed. In present-time, unlike play-time, things aren't directly editable, which means that things can't be lifted and moved unless you specifically want them to be. You will need to specify which things should be 'grabbable'... and any other interactions you'd like.
This is the "present button." Try it out. You'll notice that it gives you a full view of your Simmetri Show, but interactions are limited to those that you've specified. So lets specify some interactions we want. NOTE: Press esc to exit present mode.
- toolbox > interactions (top) > grabbable(fixed) -- what you now select will get the grabbable interaction attribute.
- select the model (hamburger). Its now grabbable in present time.
- select the sphere. Its now grabbable in present time.
You should now see the 'Grabbable' interaction node under both the Hamburger and the SphereEntity in the Hierarchy panel on Simmetri screen right.
Make the Model (hamburger) "Trigger Activating)
'Trigger activating' is an attribute that means when this object passes through a trigger, it will fire the 'onEnter' event and when it exits it fires the 'onExit' event. This means that the trigger's script will run on those events. The Sphere is by default 'trigger activating'. The hamburger is not. So lets make it so:
- Select Hamburger in space.
- Open Property Editor
- Select the little circle+triangle button next to the top left "Hamburger_mesh" icon to reveal a drop down menu.
- Select "+TriggerActivating"
- You've now made the Hamburger ready to trip the trigger and fire its onEnter event.
3) Setup the trigger with a script
We're now ready to setup --WHAT HAPPENS-- when these objects enter
Rename your objects so that we have simple names to check in the trigger script:
- Select the hamburger in the space (or in the hierarchy)
- Property Editor > name (right side) > change name to "Hamburger" --with capital "H"
Create the script:
- Select the trigger in the hierarchy panel
- Right click and "edit onEnter()code"
You should now see the Scripting Window: ...a most magical window ;)
You'll be writing the following:
function Trigger:onEnter(obj) if obj:getName() == "Hamburger" then print ("Yes! That what I wan't to eat.") else print("NO... where's the beef ? ") end end
Present, to Test Your Script:
- Press the Present Button.
- Drag the sphere into the tube(ring): see the printout at bottom left.
- Drag the hamburger into the tube(ring): see the printout at bottom left.
Make something more interesting happen:
Lets make some fireworks happen when we get the hamburger in the tube.
Create a particle emitter:
- Toolbox > Emitters (top) > Particle Emitter (bottom)
- Place the Particle emitter just in front of the ring. (bottom of screen)
- Right click to exit draw mode.
- Press play to see the emitter at work: little particle wisps will be seen shooting into the air.
Let's setup a BURST of particles when the burger enters the Trigger:
First: We don't want the particles emitting at all until the moment the burger enters. Let's turn off the particle emitter; and we'll make it burst from our script instead.
- Select the particle emitter in the space (or in the hierarchy)
- Properties > Continuous (right side, you may need to scroll the right panel) > Pulse > scroll the cursor over this 'Pulse' line and select "none" on the right side of the pulse line.
In play-time now there should be no particles emitted until we say so from script.
Finally, let's write the BURST script:
- Select the trigger in the space (or in the hierarchy)
- Right click and select "Edit Code"
- Make a few lines under the first line "print...."
- Drag the Particle Emitter icon from the hierarchy into the Scripting Window directly onto those new lines. See next gif
- Our script can now talk to our Particle Emitter.
Lets write the BURST script... Its called the emitBurst() function:
You'll add: ParticleEmitter:emitBurst(400)
The 400 is how many particles we will burst. It could be any number you want. Too many and you're computer will get slow trying to compute where they all go.
function Trigger:onEnter(obj) if obj:getName() == "Hamburger" then print ("Yes! That what I wan't to eat.") ParticleEmitter = findObjectByUid("16UJDTYCFJC9K1K31DZDDRICG4/11RX7LXA1KOIS10DX47IFC0O7I") ParticleEmitter:emitBurst(400) else print("NO... where's the beef ? ") end end
Ok! We have success!
We can build up from here. But this is foundation for a trigger that tests.
Bon appetite!
Comments
0 comments
Please sign in to leave a comment.