# Tag Info

Accepted

### I'm rotating an object on two axes, so why does it keep twisting around the third axis?

No this isn't an engine bug or an artifact of a particular rotation representation (those can happen too, but this effect applies to every system that represents rotations, quaternions included). You'...
• 135k
Accepted

### What is the standard practice for animating motion -- move character or not move character?

Animations in which the character translates away from the origin are said to contain "Root Motion" - because the root bone moves. This allows the animator to directly author subtle non-...
• 135k
Accepted

### Using Quaternions: What can I do with them? (without the maths)

Multiplication At least in terms of Unity's implementation of Quaternions, the multiplication order described in the question is not correct. This is important because 3D rotation is not commutative. ...
• 135k

### How does a 4x4 matrix represent an object in space and matrix lore?

How is Matrix Multiplication a Transformation? A matrix is just a big grid of numbers with rules that define how we can multiply it with other grids or lists of numbers. In games, we usually want to ...
• 135k

### Using Quaternions: What can I do with them? (without the maths)

Where's the dot product used? In Unity, one of the most common users of the dot product is whenever you check if two quaternions are equal via == or ...
• 611

### How and when do the model to world, world to view, et cetera multiplications happen?

Think about it logically: What is your goal when you render something? To display it on the screen! What are the constraints? The model must be visible to the camera (i.e. in the view frustum, not ...
• 501
Accepted

### In Unity, how to get reference of descendant?

Yes, transform.Find(name) will only look in the direct children of the current transform. But if you want to get a child deeper in the hierarchy, you can use ...
• 120k
Accepted

### How to mirror/reflect/flip a 4D transformation matrix

To get a transformation matrix equivalent to the one you have, but reflected across a major axis you can compose it (multiply it by) a reflection matrix. That is, if you have your input matrix M and ...
• 27.2k
Accepted

### Stop movement if transform.position.y == 0

Because the Y position is never EXACTLY 0. Its for example 5.5 next frame: 4.3 next frame: 3.1 next frame: 1.9 next frame: 0.7 next frame: -0.5 change the if to ...
• 1,450
Accepted

### How to convert a 4x4 matrix transformation to another coordinate system?

This is as easy as writing your old coordinates in terms of the new ones. We want +x to map to +x (1, 0, 0) We want +y to map to +z (0, 0, 1) We want +z to map to -y (0, -1, 0) We want the fourth, ...
• 135k
Accepted

### Extract a rotation matrix given a camera direction (vector) and a up vector for the camera?

NOTE: Edited because it was likely too verbose (source). A rotation matrix actually always defines an orthonormal basis. What this means is each column defines one of your original axes in its ...
• 166

### Detect transform from detection of QR code?

Deriving the transformation Note that the transformation of the QR code captured by the camera is a perspective transformation. As such, no amount of affine transformation can emulate it (translating,...
• 27.2k

### Calculate vector3 global point projecting it in local space using Unity and C#?

Let's say you have a trasnformed coordinate system defined by a quaternion rotation, and vector3 position. For example, the ...
• 27.2k
Accepted

### How to get an game object to instantiate lower than where It's created?

ally = (GameObject) ...is a syntax error. You need to comment this line just like you did the one below it. The problem is on that line, but because it's so ...
• 30k

### Fastest way to neutralize scale in the transform matrix?

Assuming your matrix multiplication follows the convention... M * v = (T * R * S) * v (where M is your composed matrix, ...
• 135k

### Make one object rotate to face another object in 2D

I can see this question is old, but it's a fairly common issue worth a standard answer. Quaternion.LookRotation gives us a convenient way to say "point this way" but the problem is that it wants to ...
• 135k
Accepted

### Unity / Rotate a point around an arbitrary axis and anchor

The concept of a "rotation" is represented by a Quaternion. These are built into Unity and there's no need for you to understand the math in that link you posted. To create a rotation from an angle &...
• 1,222
Accepted

### LookRotation() make X axis face the target instead of Z

I've answered a few flavours of this before. The basic idea is to chain together two rotations: one that takes the axes you want to align and points them along z+ and y+ respectively, and then the ...
• 135k
Accepted

### Why does the Debug.DrawRay return these weird lines

You're drawing Rays, not Lines. This means that the second parameter is a direction not a point in space. https://docs.unity3d.com/ScriptReference/Debug.DrawRay.html Draws a line from ...
Accepted

### Rotate object such that a child object is facing a target (3D)

Think about the problem backwards, how would we rotate C around A so that it lines up with B. If we can solve this problem, we just need to rotate A by the same amount, but in the opposite direction. ...
• 557
Accepted

### What methods can be used to rotate a tiled structure?

It sounds like you might be looking for Rotation by Shearing, or Alan Paeth's "A Fast Algorithm for General Raster Rotation" I first learned about this technique via the excellent DataGenetics blog. ...
• 135k
Accepted

### Unity RectTransformUtility.ScreenPointToLocalPointInRectangle

Preface This question starts with a small geometry problem. You have two different planes which may or may not be parallel. 1) Your screen space. This is the actual screen coordinates your computer ...
• 181
Accepted

### Efficiently calculate 2d world position based on parent(s) recursively

The way this is typically handled is with a dirty flag. Each object stores both its current local transformation/bounds, and a net transformation/bounds according to its whole parent hierarchy (eg. a ...
• 135k
Accepted

### What does the Node2D transform property do?

In games, a "transform" refers to how an object is positioned, oriented, or scaled within the game world. To move an object, to rotate an object, or to squash and stretch an object are all forms of "...
• 135k
Accepted

### In practice, is it better to store Euler angles or store three vectors represent as "front/right/up"?

So in practice, is it better to store Euler angles or vectors for axis? This totally depends on your requirements. In general, object orientations (rotations) can be represented in several ways: A ...
• 589

### In practice, is it better to store Euler angles or store three vectors represent as "front/right/up"?

Most 3D engines do neither of these things. Euler angle rotations are very messy to try to compose. If you have one object rotated on all three axes, and you want to rotate it about an arbitrary ...
• 135k
Accepted

### How to scale major and minor radius of a quarter torus

To my knowledge, this is not possible using a transformation matrix since matrices represent linear transformations and the transformation you are asking for isn't linear. The answer in this SO ...
• 589