Need help for my 2D Space Shooter

Assets\Scripts\PlayerMovement.cs(24,61): error CS1503: Argument 1: cannot convert from ‘object’ to ‘UnityEngine.Object’. I can’t figure out what the problem is.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed = 5f;

    public Rigidbody2D rb;

    Vector2 movement;

    object projectileRef;

    void Start()
    {
        projectileRef = Resources.Load("Projectile");
    }
    // Update is called once per frame
    void Update()
    {
        if(Input.GetButtonDown("Fire1"))
        {
            GameObject Projectile = (GameObject)Instantiate(projectileRef);
            Projectile.transform.position = new Vector3(transform.position.x + 0f, transform.position.y + .2f, -1);
        }
        movement.x = Input.GetAxisRaw("Horizontal");
    }

    void FixedUpdate()
    {
        rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
    }
}

wrap the instantiation on line 24 in a check to see if projectileRef != null. My theory is you do not have a game object in your resources folder that matches that string, or it cannot be converted to a GameObject.

Resources.Load
“If an asset can be found at path, it is returned with type T, otherwise returns null. If the file at path is of a type that cannot be converted to T, also returns null.”

Why do you declare projectileRef as object in the first place? Prefabs should be GameObject. Also I’m not sure what lowercase object does in this context. I think it should be Object type (no IDE at hand currently).
Your IDE should help you with types of variables and function parameters when you hover your mouse over them. Probably the cast should be more like: Instantiate((GameObject)projectileRef);
Thats all potential “issues” I can think of right now.

Lowercase object is System.Object alias. Uppercase Object is UnityEngine.Object which is not the same and should not be treated the same.

GameObjects are derived from UnityEngine.Object, however he’s trying to cast System.Object to UnityEngine.Object, and obviously you can’t do that and the cast fails. Instantiate doesn’t accept anything above UnityEngine.Object.

https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

The solution is to either declare that reference as Object, or more appropriately as GameObject. I see no reason to mix in system objects if you don’t know what you’re doing.