Nothing major here, making a 2D side scroller for fun. However reached a problem here, my two errors are:
- Assets/Scripts/Player.cs(60,33): error CS1525: Unexpected symbol `}’
- Assets/Scripts/Player.cs(96,1): error CS8025: Parsing error
I’m not very good at coding, but I have a alright grip, but I can’t solve this, everytime I do what it says it just wants me to remove a } from the next line down, until they are all gone, then it is suprised to see ‘Void Update’. Very confused right now. Thanks in advance, code below obviously ![]()
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
//Floats
public float maxSpeed = 3;
public float speed = 50f;
public float jumpPower = 150f;
//public float jumpPower2 = 100f;
//Booleans
public bool grounded;
public bool canDoubleJump;
//References
private Rigidbody2D rb2d;
private Animator anim;
void Start ()
{
rb2d = gameObject.GetComponent ();
anim = gameObject.GetComponent ();
}
void Update ()
{
anim.SetBool(“Grounded”, grounded);
anim.SetFloat (“Speed”, Mathf.Abs(rb2d.velocity.x));
if (Input.GetAxis (“Horizontal”) < -0.1f)
{
transform.localScale = new Vector3 (-1, 1, 1);
}
if (Input.GetAxis (“Horizontal”) > 0.1f)
{
transform.localScale = new Vector3 (1, 1, 1);
}
if (Input.GetButtonDown (“Jump”))
{
if(grounded)
{
rb2d.AddForce (Vector2.up * jumpPower);
canDoubleJump = true;
}
else
{
if(canDoubleJump)
{
canDoubleJump = false;
rb2d.velocity = new Vector2(rb2d.velocity.x, 0);
rb2d.AddForce (Vector2.up * jumpPower)
}
}
}
}
void FixedUpdate()
{
Vector3 easeVelocity = rb2d.velocity;
easeVelocity.y = rb2d.velocity.y;
easeVelocity.z = 0.0f;
easeVelocity.x *= 0.5f;
float h = Input.GetAxis (“Horizontal”);
//Fake friction && if(grounded) = if(grounded == true)
if (grounded)
{
rb2d.velocity = easeVelocity;
}
rb2d.AddForce (Vector2.right * speed * h);
if (rb2d.velocity.x > maxSpeed)
{
rb2d.velocity = new Vector2 (maxSpeed, rb2d.velocity.y);
}
if (rb2d.velocity.x < -maxSpeed)
{
rb2d.velocity = new Vector2 (-maxSpeed, rb2d.velocity.y);
}
}
}