Reputation: 1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EarthRotate : MonoBehaviour
{
void Update()
{
gameObject.transform.Rotate(new vector3(0, 1, 0));
}
}
Hello I am new to unity and c# as well but I am following well as far on the unity when it comes to c# scripting I am trying to follow every step correctly but every time I add the (c#) script in unity it shows me the error (error CS0246: The type or namespace name 'vector3' could not be found (are you missing a using directive or an assembly reference?))
I have tried adding different namespaces files and applied all the solutions available so far in my knowledge.
Upvotes: 0
Views: 160
Reputation: 772
Your "new vector3(0, 1, 0)" should be written as "new Vector3(0, 1, 0)", the following is the introduction of Unity's Vector3 class
Declare a quaternion:
Quaternion q1= this.transform.rotatiion;
q1 = this.transform.rotation;
Declare Vector :
Vector v1 =new Vector3(0,0,0);
v1 = this.transform.eulerAngles; //Eulerian angle of Vector3
Vector v2 =new Vector3(0,0,0);
v2 = this.transform.position; //Vector3's position;
Vector3.normalized normalization
Non-static property; return value type vector3; return the unit vector with the same direction as the original vector, if the original vector is too small, return the zero vector;
Vector3.Normalize() normalization Static function; Return value type void; Return the unit vector with the same direction as the original vector, if the original vector is too small, return the zero vector;
Vector3 v1 = this.transform.position.normalized;
Vector3 v2 = Vector3.Normalize(this.transform.position);
v1, v2 are equivalent.
vector3.magniude the length of the vector
Return the length of the vector, only the size, no direction, the return value type is float In fact, the length of the vector in the three-dimensional space is under the root sign (xx+yy+z*z)
Vector3.SqrMagnitude vector length squared
Often used for vector comparisons, because computer squaring and square root comparisons consume memory and time. There are also some that need to be found online.
Upvotes: 0
Reputation: 401
You have to use this class, you have a typo in your code: https://docs.unity3d.com/ScriptReference/Vector3.html
As the comment from @DRapp suggests, try it with an uppercase "V".
This class is part of UnityEngine
namespace, which you already included in your script.
Upvotes: 2