# Tag Info

## Hot answers tagged axis

7

Probably because that's how coordinate systems are traditionally set up when doing math. But to be honest, OpenGL can have its origin anywhere you want and its axes can point in any direction you want (well, so long as they are perpendicular to each other). If you want the origin in the top left and the Y-axis to point down, you simply set your model-view ...

5

Think back to the graphs you would draw in school. The (0,0) point is at bottom-left. Now, OpenGL is an old, old API and it's derived from an even older one. There were no gaming graphics then; 3D graphics required an expensive workstation with an expensive professional accelerator, and were used for graphing, for CAD, for other professional tasks. Hence ...

4

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 & axis, use Quaternion.AngleAxis. Once you have it, you can simply multiply it by the Vector3 you're trying to rotate. Your function would look like this: ...

2

First, it won't solve your problem, but there are a few general problems with your code. The conditions for your if branch will always be true if transform.localEulerAngles.x >= 0 and <= 360. The > 270 part is redundant since if x is less than 270, it is still possible to be >= 0. If x is 0 and lookAxisX is > 0, then adding -lookAxisX will make x < 0, ...

2

One of the two parents is rotated 90 degrees around the Y axis. I can't be sure which way, but you can "fix" this by toggling Global/Local gizmos (its one of the two buttons in the upper-left corner, just above the "scene" tab). That, or un-rotating the parent object.

2

Usually this is handled a bit differently. When manipulator is picked, you choose a movement plane (XY, YZ or XZ). Then you cast ray from cursor on to that plane and detect the hit point and move the manipulator (and object) to that location. Special cases you need to work around for are when the plane is parallel to the view and ray from cursor can reach ...

2

First of all, you need to check if the line intersects the octant. You have 3 cases: The line is completely contained within the octant (the x, y, and z coordinates of the endpoints are positive). This is the easiest one to solve, you simply draw the line as it is. One of the endpoints is outside, but one of them is inside the octant Both endpoints are ...

2

Perspective division performed on the Clip Coordinates produces Normalized Device Coordinates, ranging from -1 to 1 in all three axes. https://www.opengl.org/archives/resources/faq/technical/transformations.htm

2

You still handle it in the usual way. Make 3 perpendicular unit vectors (an orthonormal basis), expressing the directions your object's local axes should point after rotation: // Forward Y = forwardHeading; // Right X = Normalize(Cross(Y, (0, 0, 1)); // Up Z = Cross(X,Y); And then use these three vectors as the columns of a matrix: \vec {\text{rotated}} ...

1

Some semi pseudo code Change SelectDirect.Up to SelectDirect.Vertical and SelectDirect.Right to SelectDirect.Horizontal if (Mathf.Abs(selectionDirection.x) == 1) { selectDirect = SelectDirect.Horizontal; fixedY = selectedPositions[0].y; } On the case switch Horizontal you can compare SelectedPiece.position vs Vector2(SelectedPiece.x, fixedY). ...

1

When you perform a local yaw or pitch in one frame, then a local pitch or yaw in the next frame, the earlier rotation moves the axes on which the next rotation happens, which can make the results different than expected. There are a couple common ways to fix this: Pitch locally, yaw globally transform.Rotate(pitchIncrement, 0, 0, Space.Local); transform....

1

I'd recommend doing something like this: public class LocalRotator : MonoBehaviour { // Let the inspector / other scripts control how far to rotate this, // and about which local axis. public Vector3 localAxis = new Vector3(0, 1, 0); public float angleChange = 0f; // Cache your local rotation just after the object is loaded/enabled in ...

1

Rotations don't work the same as translations. They're order-dependent and their axes are not globally orthogonal - a small rotation on one axis begins to affect the results of subsequent rotations, even when you're compounding rotations in world space (since the orientation of the object relative to the rotation axis changes). See this answer for some ...

1

I don't believe that Unity has a built-in method for this. I believe that Transform.RotateAround is the closest, but if there's a utility function being used there then it isn't a documented one. Your proposed method seems clear and straightforward, and not particularly wasteful. After the compiler gets done with it, it's likely to be quite good code for ...

1

I'm not sure what your gravity compensations are doing, but you may not be taking units into account. The docs for Input.getAccelerometerY() say The rate of rotation around the y axis. (rad/s) To convert this to degrees, you have to convert from rad/s to rad then to degrees float accY = Gdx.input.getAccelerometerY(); float degrees = accY * deltaTime * ...

1

Something very simple I used on Tiny Avengers and many other mini beat'em all was to link the Y axis to the Z axis. The more the object is up the more in depth it will be. So if your character is at 25 on Y it will also be at 25 on Z... which means that a crate placed at 20 on Y will be displayed in front of the player and will give an effect of depth. ...

1

Gravity is additive. Calculate the gravity generated by planet A at point x. Then multiply by a unit vector pointing from x to A - that returns a vector, which gives the gravity a direction. Repeat for planet B, C, etc, then add the vectors. Velocity is acceleration times time. Every frame, multiply the acceleration vector by the delta time, and add the ...

1

alternatively you can create your own functions to do it, like: void drawSprite(Texture2D texture, Rectangle rect, Color color) { spriteBatch.Draw(texture, new Rectangle(/*modifying the given rectangle*/), color); }

1

I had your same problem. In my case It got fixed by closing unity and reconnecting the PS3 controller before starting Unity again. Maybe it helps

1

The PS3 controller is not directly compatible with PC. You will need a driver and a program to translate the controls to the format used on a PC. If you search the net, most articles will refer to an app called MotionInJoy but I've read many reports online that it is adware (maybe worse) and it's advised to avoid it. I've not used it but better safe than ...

1

You can always try to use the clamp method: Ref: http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html Example transform.localEulerAngles = new Vector3(Mathf.Clamp(transform.localEulerAngles.x, 0f, 90f), 0, 0); **This is just a push in the right direction (above is untested)

1

You need to do this as a hierarchy. Have a main Object that you move and run all your code on, and then add the sprite as a child object and rotate the sprite object only so it aligns the way you want it to.

1

This is a plain old bug, you're reassigning different values to the same spots, like transform[1][1] = 1+cos(rot.x); ... transform[1][1] = cos(rot.z); What you need to do is combine the rotations in the order you want them applied, like transformX[][]... assigned only from rot.x transformY[][]... assigned only from rot.y transformZ[][]... assigned only ...

1

I spent a while chasing ways to change my problem to use Euler angles, but the easy solution was actually to just 0 the components of the axis I didn't want, i.e. (in C# Unity script) Vector3 axis = Vector3.Cross(RD, RE); axis.x = CanPitch() ? axis.x : 0.0f; axis.y = CanYaw() ? axis.y : 0.0f; axis.z = CanRoll() ? axis.z : 0.0f; where RD and RE are Vector3'...

1

http://docs.unity3d.com/ScriptReference/Vector3.Lerp.html Have a look at lerp. You'll be able to move to a position over time like this: transform.position = Vector3.Lerp( start, end, currentTime / totalTime ); Where start is the initial position of the object you are moving and end is the place you want to be once currentTime = totalTime. In your case, ...

Only top voted, non community-wiki answers of a minimum length are eligible