This is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Paddle : MonoBehaviour
{
public float paddleSpeed = 1F;
public Vector3 playerPos = new Vector3(0,0,0);
}
void Update ()
{
float yPos = gameObject.transform.position.y + (Input.GetAxis (“Vertical”) * paddleSpeed);
playerPos = new Vector3 (-20,Mathf.Clamp(yPos, -11,11),0);
gameObject.transform.position = playerPos;
}
}
There should not be any curly bracket after the member variabels public Vector3 playerPos = new Vector3(0, 0, 0); }
You end the class Paddle with that end culy bracket and the compiler thinks that you are trying to enter a new class in the following line and gets confused.
Below is the corrected code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Paddle : MonoBehaviour
{
public float paddleSpeed = 1F;
public Vector3 playerPos = new Vector3(0, 0, 0);
void Update()
{
float yPos = gameObject.transform.position.y +
(Input.GetAxis("Vertical") * paddleSpeed);
playerPos = new Vector3(-20, Mathf.Clamp(yPos, -11, 11), 0);
gameObject.transform.position = playerPos;
}
}