I am currently following a guide on YouTube and have ran into a problem. I made it exactly like the guide did but for some reason I get the message "Unexpected symbol void… "
Completly new to programming btw.
Guide I am following:
Thank you in advance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public int playerspeed = 10;
public bool facingRight = true;
public int playerJumpPower = 1250;
public float moveX;
public bool isGrounded
void Update()
{
PlayerMove();
}
void PlayerMove()
{
//Controls
moveX = Input.GetAxis("Horizontal");
if (Input.GetButtonDown("Jump") && isGrounded == true)
{
Jump();
}
//Animation
// Player Direction
if (moveX < 0.0f && facingRight == false) {
FlipPlayer ();
}
else if (moveX > 0.0f && facingRight == true)
{
FlipPlayer();
}
//Physics
{
gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(moveX * playerspeed, gameObject.GetComponent<Rigidbody2D>().velocity.y);
}
}
void Jump()
{
//Jumping Code
GetComponent<Rigidbody2D>().AddForce (Vector2.up * playerJumpPower);
}
void FlipPlayer()
{
facingRight = !facingRight;
Vector2 localScale = gameObject.transform.localScale;
localScale.x *= -1;
transform.localScale = localScale;
}
void OnCollisionEnter2D(Collision2D col)
{
Debug.Log("Player has collided with" + col.collider.name);
}
}