Need help with cs8025 parsing error
Im very new to Unity (literally started today) and i started following gamesplusjames's tutorial for a 2d platformer. So far everythting went well and i solved some problems by looking at already existing threads but i can't seem to figure this one out. as i said in the title it's a paring error.
public float movespeed;
public float jumpheight;
public Transform groundCheck;
public float groundCheckRadious;
public LayerMask whatIsGround;
private bool grounded;
private bool doubleJumped;
// Use this for initialization
void Start () {
}
void FixedUpdate () {
grounded = Physics2D.OverlapCircle (groundCheck.position, groundCheckRadious, whatIsGround);
}
// Update is called once per frame
void Update () {
if (grounded)
doubleJumped = false;
if (Input.GetKey (KeyCode.D)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (movespeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.GetKey (KeyCode.A)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (-movespeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.GetKeyDown (KeyCode.Space) && grounded)
{
GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, jumpheight);
doubleJumped = true;
{
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezeRotation;
}
{
if (Input.GetKeyDown (KeyCode.Space) && grounded (!doubleJumped && !grounded))
;
} (it says the problem is here)
}
Answer by doublemax · Oct 08, 2016 at 09:05 PM
if (Input.GetKeyDown (KeyCode.Space) && grounded (!doubleJumped && !grounded))
Did you type that code from somwhere or did you write it yourself? There is an operator missing after the first "grounded". Could be a "||", but i can't be sure.
if (Input.GetKeyDown (KeyCode.Space) && grounded || (!doubleJumped && !grounded))
The problem might have come up because the tutorial was with an older version of Unity. But i added what you said and there's a parsing error on line 59, wich i think means that i haven't ended some brackets correctly since it's the last line.
using UnityEngine; using System.Collections;
public class controller : $$anonymous$$onoBehaviour {
public float movespeed;
public float jumpheight;
public Transform groundCheck;
public float groundCheckRadious;
public Layer$$anonymous$$ask whatIsGround;
private bool grounded;
private bool doubleJumped;
// Use this for initialization
void Start () {
}
void FixedUpdate () {
grounded = Physics2D.OverlapCircle (groundCheck.position, groundCheckRadious, whatIsGround);
}
// Update is called once per frame
void Update () {
if (grounded)
doubleJumped = false;
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.D)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (movespeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.A)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (-movespeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Space) && grounded)
{
GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, jumpheight);
doubleJumped = true;
{
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezeRotation;
}
{
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Space) && grounded || !doubleJumped && !grounded)
;
}
Your answer
Follow this Question
Related Questions
CS8025 Parsing Error 0 Answers
parsing error CS8025 2 Answers
error cs80525 parsing error i need help 1 Answer
Parsing error 1 Answer
Parsing Error 0 Answers