Hello!
I am playing around with the start of a C# script that will change a UI image based on a float that is changed based on a user input. I havn't played with Unity in a very long time, last time I used it was Unity 2 and now in Unity 4 they have changed the API.
Why do my public floats get the CS1525 Error "Unexpected symbol `public'"
Here's the code I have right now:
using UnityEngine;
using System.Collections;
public class Move1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
//Variables
public float thrustersMax = 100f; //Errors are concerning all of
public float thrustersMin = 0f; //the following float variables.
public float thrustersCur = 0f;
public float thrustersInc = 8f;
public Transform ThrustersUI;
//Raise Thrusters
if (Input.GetKey(KeyCode.KeypadPlus)) {
thrustersCur += thrustersInc;
}
//Lower Thrusters
if (Input.GetKey (KeyCode.KeypadMinus)) {
thrustersCur -= thrustersInc;
}
}
}
I have not added the code for changing the image in the UI yet. All I am trying to do now is when the user presses Numpad + or - the "current" value will change by an increment. My floats do not like me.
**Whats wrong with my floats?**
Thanks for help, it is appreciated!
↧