Quantcast
Channel: Latest Questions by GraviterX
Viewing all articles
Browse latest Browse all 122

Enable/Disable Child Script

$
0
0
Hey guys. I've been working on a script that makes it so that when the player presses the space bar, it disables/enables the simple mouse rotator component attached to the player and the main camera "using the standard assets beta character prefab" However, I'm getting these errors: Modified Cursor.js(6,62): BCE0005: Unknown identifier: 'SimpleMouseRotator'. and Modified Cursor.js(7,54): BCE0005: Unknown identifier: 'SimpleMouseRotator'. Can someone tell me what I did wrong? The Script: var changeToggle : boolean; var script : SimpleMouseRotator; var script2 : SimpleMouseRotator; function Start() { script = GameObject.Find("Main Camera").GetComponent(SimpleMouseRotator); script2 = GameObject.Find("Player").GetComponent(SimpleMouseRotator); } function Update (){ if (Input.GetKeyDown("space")){ if(changeToggle) Screen.lockCursor = true; script.enabled = true; script2.enabled = true; } else { script.enabled = false; script2.enabled = false; Screen.lockCursor = false; changeToggle = !changeToggle; } }

Viewing all articles
Browse latest Browse all 122

Latest Images

Trending Articles



Latest Images

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