I am programming
using UnityEngine;
public class playermove : MonoBehaviour
{
public float moveSpeed=5f;
// Update is called once per frame
void Update()
{
jump();
Vector3 movment = new Vector3(Input.GetAxis("Horizontal"),0f ,0f);
transform.position += movment * Time.deltaTime * moveSpeed;
}
void jump()
{
if (Input.GetButtonDown("jump"))
{
GameObject.GetComponent("RigidBody2D")().AddForce(new Vector2(0f,5f),ForceMode2D.Impulse);
}
}
}
and I am getting this problem:
(15,1): error CS0120: An object reference is required for the non-static field, method, or property 'GameObject.GetComponent(string)'