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

Namespace Errors

$
0
0
I am extremely new to C# and scripting in general. I am getting three errors in my script: Assets/Scripts/PlayerHealth.cs(25,14): error CS0116: A namespace can only contain types and namespace declarations Assets/Scripts/PlayerHealth.cs(28,14): error CS0116: A namespace can only contain types and namespace declarations Assets/Scripts/PlayerHealth.cs(31,21): error CS0116: A namespace can only contain types and namespace declarations I have absolutely no clue what they mean or how to fix them. My full script is: using UnityEngine; using System.Collections; public class PlayerHealth : MonoBehaviour { public int maxHealth = 100; public int curHealth = 100; public float healthBarLength; void Start() { healthBarLength = (Screen.width / 1); InvokeRepeating("HealthDrop", 9f, 9f); } void HealthDrop() { curHealth -= 1; } } void Update () { AdjustCurrentHealth (0); } void OnGUI() { GUI.Box (new Rect (4, 4, healthBarLength, 8), curHealth + "/" + maxHealth); } public void AdjustCurrentHealth(int adj) { curHealth += adj; if(curHealth < 0) curHealth = 0; if(curHealth > maxHealth) curHealth = maxHealth; if (maxHealth < 1) maxHealth = 1; healthBarLength = (Screen.width / 1) * (curHealth / (float)maxHealth); } Thank you for your time and any help.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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