Ataloss Tutorial 2- Show & Hide loop (without bools)

Post a link here for written or video tutorials on uScript.
Post Reply
User avatar
ataloss
Contributor
Posts: 65
Joined: Mon Mar 31, 2014 9:02 pm

Ataloss Tutorial 2- Show & Hide loop (without bools)

Post by ataloss »

Ataloss Uscript Tutorial 2- Show/Hid loop (Without using Bool)
Link to the PDF Version of this tutorial: http://tinyurl.com/mmbfdvg

Hello everyone. For the longest time I've experimented on how to make a toggle without using Bool's. Today I am finally able to do it. This tutorial will show you how to toggle two objects without using a bool, but by using two Toggle Component nodes.

I will later make another version of this tutorial with animations. For those that want to be able to toggle animations (for example open door animation & close door animation).


If you're an intermediate or advanced uScript user, jump to the bottom of this tutorial that displays the entire graph. For everyone else,...let's begin.


1- After creating your scene. Create two objects. For this tutorial I created a Capsule and a Sphere. Ignore the Cube.
Image



In your inspector window hide the Mesh Renderer of the Sphere by unchecking the box.
Image



2- In uScript create a Input Events Node (use the search bar to find it).
Image



Create a Owner GameObject.
Image



Connect the Owner GameObject to the Instance node.



3- Create a Input Events Filter (use the search bar to find it).
Image



Here is what I have in my node (nothing special).
Image



4- Create TWO Toggle Component nodes.
Image



Drag your Sphere object into the uScript window. Then choose Place Variable: GameObject. you should see this.
Image



Drag your Capsule object into the uScript window. Then choose Place Variable: GameObject. you should see this.
Image



5- Connect the Sphere GameObject to “target” on the the FIRST Toggle Component node.
Image



Click on the FIRST Toggle Component node, your screen should look like this.
Image



This is why you unchecked the Mesh Renderer on the Sphere earlier. You're telling Unity to hide the mesh of that object when the play button is used. Then when you press “G” on the keyboard you're telling Unity to unhide that object.



6- Connect the Capsule to “Target” on the SECOND Toggle Component.
Image



Click on the SECOND Toggle Component node and it should look like this.
Image



7- Your screen should look like this after connecting your nodes.
Image



8- Save your Graph as whatever you want.

9- Assign it to the Master Game object (for the sake of this tutorial).
Image



10- Press the play button to test the scene. When you press G the Sphere should appear and the Capsule disappears. Press it again and the opposite effect will happen.


Here is the graph for you more experienced users. As usual I like to keep things simple as possible. I hope this will be helpful to someone.

-------------------------------------
Link to my previous Tutorial
Random Text Asset-viewtopic.php?f=18&t=3015
Attachments
show_hide_loop_20140420_15064134.png
Post Reply