The type or namespace could not be found:s

Hey everyone, So I should probably start by saying i’m extremely new to unity, so there’s a chance this is something very simple… But I have something that I’ve coded, all it’s meant to do is send some variables to a php file, however I’m getting an error and i’m really not sure why, and google hasn’t proved much use:S

Here’s my code

using UnityEngine;

public class PostURL : MonoBehaviour {

    void Start () {
		var pos = Vector3;
		var user = database.userr;
        string url = "http://www.website.com/storepos.php";
        WWWForm form = new WWWForm();
        form.AddField("position", pos);
        form.AddField("user", user);
        WWW www = new WWW(url, form);

        StartCoroutine(WaitForRequest(www));
    }

    IEnumerator WaitForRequest(WWW www){
        yield return www;

        // check for errors
        if (www.error == null)
        {
            Debug.Log("WWW Ok!: " + www.data);
        } else {
            Debug.Log("WWW Error: "+ www.error);
        }    
    }    
}

The error I’m getting is :

So I assume the error is on line 17?

Googling that error hasn’t gave me any luck however, Any help would be much appreciated guys, Really quite stuck here o.0, Thanks very much in advance.

If that’s what it actually says, then you made a typo in your code there. Although that’s not in the code you posted.

–Eric

At line 17 seems to be correct! Please check the compiler outputs for futher error.

-Jhoemar

Ah I didn’t copy the error I typed it, The error is the same minus the typo, and the output is just as follows:

:confused: any ideas?

You seem to be missing this;

using System.Collections;

Put that at the top.

17 Likes

Can someone help i know im a noobe lol
Trying to add photon multilayer with spawn respawn on die Can any legend see the problem

I get this error everything else works fine
Assets/Photon Unity Networking/UtilityScripts/NetworkManager.cs(7,9): error CS0246: The type or namespace name `spawn’ could not be found. Are you missing a using directive or an assembly reference?

You are a life saver

1 Like

Thanks! I had the same error and this fixed it for me as well! =)

1 Like

Almost 6 years later, you helped me too :slight_smile:

i dont know what to say you saved my life

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

public class MovementScript : MonoBehaviour
{
    public bool isMoving = false;
    public float movementSpeed = 20f;
    public RigidBody rb;
    public float jumpAmount = 10f;
    public float rage = 1f;
    public bool grounded = false;
    public Camera GroundedCam;
    public float horizontalSpeed = 1.0f;
    float v;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = Cursor.LockMode.Locked;
      
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            transform.position += transform.forward * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.S))
        {
            transform.position -= transform.forward * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.D))
        {
            transform.position += transform.forward * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.A))
        {
            transform.position -= transform.forward * Time.deltaTime * movementSpeed;
        } 

        ShootRaycast();

        if (Input.GetKeyDown(KeyCode.Space) & grounded == true)
        {
            rb.AddForce(Vector3.up * jumpAmount, ForceMode.Impulse);
        }

        float h = horizontalSpeed * Input.GetAxis("Mouse X");
        transform.Rotate(v, h, 0);   
    }

    void ShootRaycast()
    {
        RaycastHit hit;
        if (Physics.Raycast(GroundedCam.transform.position, GroundedCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);

            Target target = hit.transform.GetComponent<Target>();
            if(target != null)
            {
                StartCoroutine(JumpBool());
            }
        }
    }

    IEmumerator JumpBool()
    {
        grounded = true;
        yield return new WaitForSeconds(0.1f);
        grounded = false;
    }

}

Nothing was missing then this happened

Assets\Scenes\MovementScript.cs(9,12): error CS0246: The type or namespace name ‘RigidBody’ could not be found (are you missing a using directive or an assembly reference?)
I dont know whats missing

Nothing is missing. You have just spelled Rigidbody incorrectly.
Capitalisation matters. If in doubt, look at the manual and you will see how you have typed it wrong.

Also you should not be necroing a topic for this, when you should be creating your own topic.

Please create your own threads, don’t necro/hijack others.