Unity Vector3



  • 用于编写 Vector3(0, 0, -1) 的简便方法。. 'Unity'、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。 公安部备案号: 2961.
  • And thank you for taking the time to help us improve the quality of Unity Documentation. Your name Your email Suggestion. Submit suggestion. Public static Vector3 operator. (Vector3 a, float d); Description. Multiplies a vector by a number. Multiplies each component of a by a number d. // make the vector twice longer: prints (2.
-->

Definition

In unity3D you can declare a Vector3 like this: var myVector = Vector3(1,2,1); Your code has the following faults: You didn't write var before cubeVector; You didn't end your line with. Unity - converting a Quaternion to a Vector3. Ask Question Asked 9 months ago. Active 9 months ago. Viewed 2k times 1. I've seen quite a lot of questions like this, and the trouble is - the question makes no sense. They are not the same thing, it is a bit like saying 'how do I convert an apple into a brick'? But usually the underlying question. Unity 基础 - Vector3. Vector 是向量,矢量的意思,向量既有大小,又有方向,Verctor3 就是三维向量,一个三维向量会有三个分量,分别是 x,y,z,在 Unity 中每一个游戏对象都至少会有一个组件叫 Transform,Transform 主要用来控制游戏对象的位置,旋转和缩放。.

Represents a vector with three single-precision floating-point values.

Inheritance
Vector3
Implements

Remarks

The Vector3 structure provides support for hardware acceleration.

For matrix transformations, the Vector2, Vector3, and Vector4 instances are represented as rows: a vector v is transformed by a matrix M with vM multiplication.

Constructors

Vector3(Single)

Creates a new Vector3 object whose three elements have the same value.

Vector3(Single, Single, Single)

Creates a vector whose elements have the specified values.

Vector3(Vector2, Single)

Creates a new Vector3 object from the specified Vector2 object and the specified value.

Fields

X

The X component of the vector.

Y

The Y component of the vector.

Z

The Z component of the vector.

Properties

One

Gets a vector whose 3 elements are equal to one.

UnitX

Gets the vector (1,0,0).

UnitY

Gets the vector (0,1,0).

UnitZ

Gets the vector (0,0,1).

Zero

Gets a vector whose 3 elements are equal to zero.

Methods

Abs(Vector3)

Returns a vector whose elements are the absolute values of each of the specified vector's elements.

Add(Vector3, Vector3)

Adds two vectors together.

Clamp(Vector3, Vector3, Vector3)

Restricts a vector between a minimum and a maximum value.

CopyTo(Single[])

Copies the elements of the vector to a specified array.

CopyTo(Single[], Int32)

Copies the elements of the vector to a specified array starting at a specified index position.

Cross(Vector3, Vector3)

Computes the cross product of two vectors.

Distance(Vector3, Vector3)

Computes the Euclidean distance between the two given points.

DistanceSquared(Vector3, Vector3)

Returns the Euclidean distance squared between two specified points.

Divide(Vector3, Single)

Divides the specified vector by a specified scalar value.

Divide(Vector3, Vector3)

Divides the first vector by the second.

Dot(Vector3, Vector3)

Returns the dot product of two vectors.

Equals(Object)

Returns a value that indicates whether this instance and a specified object are equal.

Equals(Vector3)

Returns a value that indicates whether this instance and another vector are equal.

GetHashCode()

Returns the hash code for this instance.

Length()

Returns the length of this vector object.

LengthSquared()

Returns the length of the vector squared.

Lerp(Vector3, Vector3, Single)

Performs a linear interpolation between two vectors based on the given weighting.

Max(Vector3, Vector3)

Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.

Min(Vector3, Vector3)

Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.

Multiply(Single, Vector3)

Multiplies a scalar value by a specified vector.

Multiply(Vector3, Single)

Multiplies a vector by a specified scalar.

Multiply(Vector3, Vector3)

Returns a new vector whose values are the product of each pair of elements in two specified vectors.

Negate(Vector3)

Negates a specified vector.

Normalize(Vector3)

Returns a vector with the same direction as the specified vector, but with a length of one.

Reflect(Vector3, Vector3)

Returns the reflection of a vector off a surface that has the specified normal.

SquareRoot(Vector3)

Returns a vector whose elements are the square root of each of a specified vector's elements.

Subtract(Vector3, Vector3)

Subtracts the second vector from the first.

ToString()

Returns the string representation of the current instance using default formatting.

ToString(String)

Returns the string representation of the current instance using the specified format string to format individual elements.

ToString(String, IFormatProvider)

Returns the string representation of the current instance using the specified format string to format individual elements and the specified format provider to define culture-specific formatting.

Transform(Vector3, Matrix4x4)

Transforms a vector by a specified 4x4 matrix.

Transform(Vector3, Quaternion)

Transforms a vector by the specified Quaternion rotation value.

TransformNormal(Vector3, Matrix4x4)

Transforms a vector normal by the given 4x4 matrix.

Operators

Addition(Vector3, Vector3)

Adds two vectors together.

Division(Vector3, Single)

Divides the specified vector by a specified scalar value.

Division(Vector3, Vector3)

Divides the first vector by the second.

Equality(Vector3, Vector3)

Returns a value that indicates whether each pair of elements in two specified vectors is equal.

Inequality(Vector3, Vector3)

Returns a value that indicates whether two specified vectors are not equal.

Multiply(Single, Vector3)

Multiples the scalar value by the specified vector.

Multiply(Vector3, Single)

Multiples the specified vector by the specified scalar value.

Multiply(Vector3, Vector3)

Returns a new vector whose values are the product of each pair of elements in two specified vectors.

Subtraction(Vector3, Vector3)

Subtracts the second vector from the first.

UnaryNegation(Vector3)

Negates the specified vector.

Extension Methods

AsVector128(Vector3)

Reinterprets a Vector3 as a new Vector128<T>.

Unity Vector3 Lerp

Unity constant vector3

Unity Vector3

Applies to