I am new to c sharp and am following a tutorial but I am getting 4 errors that I cant understand from what is see the code looks the same but mine isn't working.
![alt text][1]
[1]: /storage/temp/199650-screenshot-2022-09-08-213314.png
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerMovement : MonoBehaviour
{
Rigidbody rb;
[SerializeField] float movementSpeed = 6f;
[SerializeField] float jumpForce = 5f;
[SerializeField] Transform groundCheck; // problem was triggered when putting in this line and one further down
// Start is called before the first frame update
void Start()
{
rb = GetComponent();
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
rb.velocity = new Vector3(horizontalInput * movementSpeed, rb.velocity.y, verticalInput * movementSpeed);
if (Input.GetButtonDown("Jump"))
{
rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
}
}
bool IsGrounded() // this part also triggered the errors
{
return true;
}
}
* Edited by wideeyenow_unity : reason : Duplicated text
↧