- Home /
Question by
blankfaced · Nov 28, 2012 at 09:30 PM ·
c#errorhelicopter
Error with 'public' on script for helicopter
When I put my script in and save it, Unity gives me an error. "Assets/FlightScript.cs(7,18): error CS1525: Unexpected symbol 'public'"
And
"Assets/FlightScript.cs(9,10): error CS1525: Unexpected symbol 'public'"
Here's the code. VVV
using UnityEngine;
using System.Collections;
public class FlightScript : MonoBehaviour {
void Start () {
public float AmbientSpeed = 100.0f;
public float RotationSpeed = 200.0f;
}
void UpdateFunction() {
Quaternion AddRot = Quaternion.identity;
float roll = 0;
float pitch = 0;
float yaw = 0;
roll = Input.GetAxis("Roll") * (Time.deltaTime * RotationSpeed);
pitch = Input.GetAxis("Pitch") * (Time.deltaTime * RotationSpeed);
yaw = Input.GetAxis("Yaw") * (Time.deltaTime * RotationSpeed);
AddRot.eulerAngles = new Vector3(-pitch, yaw, -roll);
rigidbody.rotation *= AddRot;
Vector3 AddPos = Vector3.forward;
AddPos = Ship.rigidbody.rotation * AddPos;
rigidbody.velocity = AddPos * (Time.deltaTime * AmbientSpeed);
}
}
(IT IS A C# CODE, NOT JAVA)
Comment
Answer by Michael Covert · Nov 28, 2012 at 09:48 PM
Your variables you declare in your start function can't be public. If you want them public, declare them outside start, and initialize them in start.
Something like:
public float AmbientSpeed;
public float RotationSpeed;
void Start () {
AmbientSpeed = 100.0f;
RotationSpeed = 200.0f;
}
or
public float AmbientSpeed = 100.0f;
public float RotationSpeed;
void Start() {
//now empty, but you could put other stuff here later if you need it
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
NullReferenceException 1 Answer
Distribute terrain in zones 3 Answers
Error (Read Only) 1 Answer
Error cs0200, please help i´m novice 1 Answer