Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Getting public variable from another component

$
0
0
In my game I have a line of code that is getting my PlayerController script, and setting it to a private variable, playerhealth. Next it should set it to a text element, but it doesn't. This is the error I get: ![alt text][1] This is the code on the line it says: playerHealth = gameObject.GetComponent().PlayerHealth; I also get another error saying that it cannot convert float to string (to set the text), I also do not know how to resolve this. I have no idea on what this means and i have no idea what to do. I have tried to research this but got nothing. Here is a link to my whole code: https://gist.github.com/avanti534/88d0d956e014b9fbb4d4 Here is a image that may help: ![alt text][2] [1]: /storage/temp/66612-screenshot-2016-03-24-154826.png [2]: /storage/temp/66611-screenshot-2016-03-24-160325.png

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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