"'UnityEngine.vector3' is a 'type' but is used as a 'variable'' error.

I have little knowledge regarding ths error. I thought I was following this tutorial pretty decently, but at roughly 6 minutes I run into this error:


I don’t know how to deal with this error other than posting on this forum about it. I tried Google-ing it, but my search came back with no acceptable results. Thanks if you’ll help me.

Try this :

rigidbody.velocity = new Vector3(moveHorizontal, 0.0f, moveVertical);

and find a book about C#, with the language basics, one that teaches you what are variables, classes, etc.

When I change it to that I get an " ‘UnityEngine.Component’ does not contain a definition method ‘velocity’ acceptng a first arguement of type ‘UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)" error on my “rigidbody.velocity” line.

Am I missing a using directive or an assembly reference?

How to use Rigidbody.velocity:

Something like this probably works:

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

private Rigidbody myRigidbody;

void Start ()
{
    myRigidbody = GetComponent<Rigidbody>();
}

void FixedUpdate()
{
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");

    myRigidbody.velocity = new Vector3(moveHorizontal, 0.0f, moveVertical);
}

Also, post your code using code tags instead of images. It makes it easier for people to make changes to your code and show it to you rather than just throwing single command ideas at you.

Sorry I forgot that using the rigidbody property of the gameobject no longer worked, use the code Joe posted above and it will work.

I tried Joe-Censored’s code and now it’s saying “Unexpected symbol ‘Rigidbody’, expecting ‘class’, ‘delegate’, ‘enum’, ‘partial’ or ‘sruct’” for the line

private Rigidbody myRigidbody;

He forgot the class declaration, here :

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

public class PlayerController : MonoBehaviour
{
private Rigidbody myRigidbody;
void Start ()
{
    myRigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");
    myRigidbody.velocity = new Vector3(moveHorizontal, 0.0f, moveVertical);
}
}