I'm really new to unity and I watched a lot of videos for roll a ball here's the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float speed = 0;
private Rigidbody rb;
private float movementX;
private float movementY;
// Start is called before the first frame update
void Start()
{
rb = GetComponent();
}
public void OnMove(InputValue movementValue)
{
Vector2 movementVector = movementValue.Get();
movementX = movementVector.x;
movementY = movementVector.y;
}
private void FixedUpdate()
{
Vector3 movement = new Vector3(movementX, 0.0f, movementY);
rb.AddForce(movement * speed);
}
}
And here is the list of errors i'm getting
1. Assets\Scripts\PlayerController.cs(6,14): error CS0101: The namespace '' already contains a definition for 'PlayerController'
2. Assets\Scripts\PlayerController.cs(16,10): error CS0111: Type 'PlayerController' already defines a member called 'Start' with the same parameter types
3. Assets\Scripts\PlayerController.cs(21,17): error CS0111: Type 'PlayerController' already defines a member called 'OnMove' with the same parameter types
4. Assets\Scripts\PlayerController.cs(29,18): error CS0111: Type 'PlayerController' already defines a member called 'FixedUpdate' with the same parameter types
I have no idea what any of these errors mean and i was thinking the video might of been outdated but then again i wasnt sure so can someone please help me!
↧