- Home /
2D toolkit scripting error - Very Basic Stuff
Hello, I'll say outright that I'm kinda a begginer programing in unity (but know programing in general), see the thing is Unity says there's an error (the same error in several scripts) in a certain script pattern I use , so it must be me doing something wrong obviously but I can't see the error, so if you guys are kind enought to point why it is wrong and how to fix it'll be very much appreciated.
Heres a code sample:
using UnityEngine; using System.Collections;
public class JacobWalkScript : MonoBehaviour {
private bool Idle_Jacob = true;
private bool Walking_Jacob =false;
private bool Facing_Left = false;
private float Movement_Speed = 0.25;
private tk2dAnimatedSprite Jacob;
private void Awake()
{
Jacob = GetComponent<tk2dAnimatedSprite>();
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.RightArrow){ *Error Number 1*
if (!Jacob.IsPlaying("walk")) {
Jacob.Play("walk");
Jacob.AnimationCompleted = null;
Walking_Jacob = true;
Idle_Jacob = false;
}
}
} *Error Number 2*
}
Here is the unity console error report:
Number 1
Assets/DreamBound Story/Jacob/Walk Animation/Images/JacobWalkScript.cs(25,53): error CS1525: Unexpected symbol `{'
Number 2
Assets/DreamBound Story/Jacob/Walk Animation/Images/JacobWalkScript.cs(33,9): error CS8025: Parsing error
The Error Number... is to point where it says there's the error.
I really can't see the fault X_X
Answer by mattssonon · Aug 20, 2013 at 05:32 PM
First error, you're missing a curly bracket after Input.GetKey(KeyCode.RightArrow
, the entire line should be if (Input.GetKey(KeyCode.RightArrow)){
. This will properly fix the second error, too. Let me know if it doesn't.
You're also missing an 'f' in the top, private float Movement_Speed = 0.25;
should be private float Movement_Speed = 0.25f;
.
Your answer
Follow this Question
Related Questions
Null in GetValidMethodInfo 0 Answers
A node in a childnode? 1 Answer
press play, game objects get deleted, game breaks. 1 Answer
Targetting error please help 0 Answers