I'm just getting started with Unity and I don't know why I'm getting these errors:
Assets\PlayerMovementScript.cs(15,19): error CS1513: } expected
Assets\PlayerMovementScript.cs(48,1): error CS1022: Type or namespace definition, or end-of-file expected
I've double-checked all the curly brackets and it doesn't seem wrong to me. Any clue of what could be happening here? I'm sorry if it's a dumb question, but I can't find what the problem is. Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovementScript : MonoBehaviour {
public KeyCode upKey = KeyCode.W;
public KeyCode downKey = KeyCode.S;
public KeyCode rightKey = KeyCode.D;
public KeyCode leftKey = KeyCode.A;
public float speed = 4.0f;
public Vector3 pos = player.transform.position;
void Start() {
public GameObject player = GameObject.Find("Player");
}
void Update() {
if (Input.GetKeyDown(upKey))
{
pos.y += speed * Time.deltaTime;
}
if (Input.GetKeyDown(downKey))
{
pos.y -= speed * Time.deltaTime;
}
if (Input.GetKeyDown(rightKey))
{
pos.x += speed * Time.deltaTime;
}
if (Input.GetKeyDown(leftKey))
{
pos.x -= speed * Time.deltaTime;
}
player.transform.position = pos;
}
}
Thanks in advance!
↧