I got this error witch it says that their is an problem with forward but I don't know what is the problem the problem is in line 41 can someone pleas help

using UnityEngine;
using System.Collections;
using System;

public class Press_Space_to_Fire :  MonoBehaviour
   
{
    //Drag in the Bullet Emitter from the Component Inspector.
    public GameObject Bullet_Emitter;

    //Drag in the Bullet Prefab from the Component Inspector.
    public GameObject Bullet;

    //Enter the Speed of the Bullet from the Component Inspector.
    public float Bullet_Forward_Force;
    private object  transform;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("Fire1"))
        {
            //The Bullet instantiation happens here.
            GameObject Temporary_Bullet_Handler;
            Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

            //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
            //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
            Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);

            //Retrieve the Rigidbody component from the instantiated Bullet and control it.
            Rigidbody Temporary_RigidBody;
            Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent<Rigidbody>();

            //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
            Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

            //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
            Destroy(Temporary_Bullet_Handler, 10.0f);
        }
    }

    private void Destroy(GameObject temporary_Bullet_Handler, float v)
    {
        throw new NotImplementedException();
    }

    private GameObject Instantiate(GameObject bullet, Vector3 position, Quaternion rotation)
    {
        throw new NotImplementedException();
    }
}

You’re creating a variable at the start:

   private object  transform;

but you’re not actually setting this as anything anywhere.

The first, and only time the variable is used in the provided code is here:

Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

At line 40, the part that is causing you the issue. But as I said transform is not being set anywhere.

Also take note that you’re using the C# definition of ‘object’, and not the Unity definition ‘Object’ just in case that wasn’t your intention. But the error is essentially telling you that the variable transform does not define ‘forward’ in anyway which is - as said above - simply because the variable you’ve declared hasn’t been set yet, and has nothing.

If you’re trying to use the Unity’s built in transform component which does have a definition for forward, then delete that private declaration, and use ‘this.transform.forward’, or if you do need that variable for something, then you can still use ‘this.gameObject.transform.forward’. So here hope this helps:

 Temporary_RigidBody.AddForce(this.gameObject.transform.forward * Bullet_Forward_Force);

-O-

I can give two possible answers. If you NEED the variable declared at line 16 the one presented in the first code snippet in my answer above ‘private object transform’ for some reason, then here is a possible answer:

using UnityEngine;
using System.Collections;
using System;

public class Press_Space_to_Fire : MonoBehaviour

{
    //Drag in the Bullet Emitter from the Component Inspector.
    public GameObject Bullet_Emitter;

    //Drag in the Bullet Prefab from the Component Inspector.
    public GameObject Bullet;

    //Enter the Speed of the Bullet from the Component Inspector.
    public float Bullet_Forward_Force;
    private object transform;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("Fire1"))
        {
            //The Bullet instantiation happens here.
            GameObject Temporary_Bullet_Handler;
            Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

            //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
            //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
            Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);

            //Retrieve the Rigidbody component from the instantiated Bullet and control it.
            Rigidbody Temporary_RigidBody;
            Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent<Rigidbody>();

            //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
            Temporary_RigidBody.AddForce(this.gameObject.transform.forward * Bullet_Forward_Force);

            //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
            Destroy(Temporary_Bullet_Handler, 10.0f);
        }
    }

    private void Destroy(GameObject temporary_Bullet_Handler, float v)
    {
        throw new NotImplementedException();
    }

    private GameObject Instantiate(GameObject bullet, Vector3 position, Quaternion rotation)
    {
        throw new NotImplementedException();
    }
}

BUT if you DON’T need that line for any reason, then here is another possible answer in that case:

using UnityEngine;
using System.Collections;
using System;

public class Press_Space_to_Fire : MonoBehaviour

{
    //Drag in the Bullet Emitter from the Component Inspector.
    public GameObject Bullet_Emitter;

    //Drag in the Bullet Prefab from the Component Inspector.
    public GameObject Bullet;

    //Enter the Speed of the Bullet from the Component Inspector.
    public float Bullet_Forward_Force;
    //private object transform;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("Fire1"))
        {
            //The Bullet instantiation happens here.
            GameObject Temporary_Bullet_Handler;
            Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

            //Sometimes bullets may appear rotated incorrectly due to the way its pivot was set from the original modeling package.
            //This is EASILY corrected here, you might have to rotate it from a different axis and or angle based on your particular mesh.
            Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);

            //Retrieve the Rigidbody component from the instantiated Bullet and control it.
            Rigidbody Temporary_RigidBody;
            Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent<Rigidbody>();

            //Tell the bullet to be "pushed" forward by an amount set by Bullet_Forward_Force.
            Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

            //Basic Clean Up, set the Bullets to self destruct after 10 Seconds, I am being VERY generous here, normally 3 seconds is plenty.
            Destroy(Temporary_Bullet_Handler, 10.0f);
        }
    }

    private void Destroy(GameObject temporary_Bullet_Handler, float v)
    {
        throw new NotImplementedException();
    }

    private GameObject Instantiate(GameObject bullet, Vector3 position, Quaternion rotation)
    {
        throw new NotImplementedException();
    }
}

Thanks for answer but I still don’t get what you mean can you pleas fix the problem and posting it here so I can copy and past it THANKS.