Quantcast
Channel: Questions in topic: "parenting"
Viewing all articles
Browse latest Browse all 302

Toogle Parent to Camera Function - Google Cardboard

$
0
0
Hi, I'm trying to test the google cardboard SDK. I wanted to create a Cube that on click (tap-magnetic trigger) parents itself to the 'Main Camera' (Camera Object name) and on the second click unparents itself. I'm tried to create a function called 'ToogleParent' to attach it to the event trigger 'Pointer Click' of the cube. But sadly it doesn't work. I'm very new to Unity and C# and can't get it to work. This is the code I used in the Cube's Script: public void ToggleParent() { if (transform.parent = null) { transform.parent = GameObject.Find("Main Camera").transform.parent; } else if (transform.parent != null){ transform.parent = null; } } I'm very sure this is wrong but I'm trying to find out how to reference the Main Camera. Is there a better way to do this. Thanks :)

Viewing all articles
Browse latest Browse all 302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>