Please I’m just starting out on Unity and am getting this error message - Assets\Scripts\PlayerMovement.cs(44,82): error CS1002: ; expected, I need help sorting it out…
This is my Code… Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
// This is a reference to the Rigidbody component called "rb"
public Rigidbody rb;
public float forwardForce = 2000f;
public float sidewaysForce = 500f;
private Vector2 lastMousePos;
// We marked this as "Fixed"Update because we
// are using it to mess with physics.
void FixedUpdate()
{
// Add a forward force
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
if (Input.GetKey("d"))
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey("a"))
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
Vector2 deltaPos = Vector2.zero;
if (Input.GetMouseButton(0))
{
Vector2 currentMousePos = Input.mousePosition;
if (lastMousePos == Vector2.zero)
lastMousePos = currentMousePos;
deltaPos = currentMousePos = lastMousePos;
lastMousePos = currentMousePos;
Vector3 force = new Vector3(deltaPos.x, 0, deltaPos.y) + forwardForce
rb.AddForce(force);
}
else
{
lastMousePos = Vector2.zero;
}
}
}