Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrea Notarstefano
1,428 PointsI've followed the lessons to the letter but Unity doesn't work
Hello, I'm new in Unity.
I'm following the lesson track on the basics on making a videogame, but I'm stuck in a few points.
Mainly is the code. I've copied the lessons and rechecked, but often it leaves me with parse errors (unexpected symbols) or can't apply values to float anymore (stuck to nul for some reason). As an example I have a script from Object-Oriented Prog. in Unity course:
using UnityEngine; using System.Collections;
public class MovingTarget : Target {
[SerializeField]
private float amplitude = 1f;
[SerializeField]
private float timePeriod = 1f;
private Vector3 startPosition;
private bool movement = true
// Use this for initialization
protected override void Start () { (unexpected symbol "protected")
base.Start ();
// Store the start position
startPosition = transform.localPosition; (unexpected symbol "=")
}
void LateUpdate () { (unexpected symbol "void")
if (Moving) {
// Calculate theta
float theta = Mathf.Sin (Time.timeSinceLevelLoad / timePeriod);
// Create the new delta position
Vector3 deltaPosition = new Vector3 (amplitude, 0f, 0f) * theta;
// Update the position by adding the start position and delta position
transform.localPosition = startPosition + deltaPosition;
}
}
protected override void OnCollisionEnter (Collision other) {
if (other.gameObject.ComareTag("Arrow")) {
moving = false;
}
base.OnCollisionEnter (other);
}
public override void DestroyTarget() {
// Disable target movement
moving = false;
base.DestroyTarget ();
}
}
I don't get what I'm doing wrong. Is it some compatibility issue?