# Questions tagged [rotation]

Rotation is the circular movement of an object around a specific axis.

132 questions
Filter by
Sorted by
Tagged with
31k views

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

I see questions come up quite often that have this underlying issue, but they're all caught up in the particulars of a given feature or tool. Here's an attempt to create a canonical answer we can ...
• 136k
2k views

### Why rotating an object only on its local X axis result in sudden 180 degrees changes in Y and Z axis rotation values

I have an object (cube) in the scene and I want it to continuously rotate on its only local X axis but suddenly while rotating on X axis its Y and Z axis rotation value goes 180 degrees for some ...
15k views

### How can I rotate about an arbitrary point in 3D (instead of the origin)?

I have some models that I want to rotate using quaternions in the normal manner, except instead of rotation about the origin, I want it to be offset slightly. I know that you don't say, in 3d space, ...
• 3,887
2k views

### Unity smooth local rotation around one Axis, oriented toward a target

I want to acheive the same rotation you see in the inspector. In short: a smooth local Y rotation, toward a target I have a Vector3 orientation: ...
• 281
58k views

### How can I orbit a camera about it's target point?

I'm drawing a scene where the camera freely moves about the universe. The camera class keeps track of the view (or look at) point, the position of the camera, and the up vector. These vectors/points ...
• 355
6k views

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

I am a Game Developer and did not study Mathematics. So I only want to use Quaternions as a tool. And to be able to work with 3D rotation, it's necessary to use Quaternions (Or Matrixes, but let's ...
• 1,460
16k views

### How to avoid gimbal lock

I am trying to write code with rotates an object. I implemented it as: Rotation about X-axis is given by the amount of change in y coordinates of a mouse and Rotation about Y-axis is given by the ...
• 203
6k views

### Why is the camera tilting around the z axis when I only specified x and y? [duplicate]

My goal is to program a camera to point towards the mouse cursor. I attached the following script to the Main Camera. ...
• 143
1 vote
4k views

### Lookrotation of a gameObject in just one axis

So I am trying to orient a gameObject ( house in the picture below) which is nothing but a plane and has a 2d texture on it as you see below. The whole game is made on a hex sphere. I am using ...
• 425
2k views

### Turning a sprite such that it rotates in the direction that's most efficient

I have a sprite that moves from waypoint to waypoint. It turns to face its velocity vector, but not instantly (there's a rotation speed). The problem I'm having is, from one direction to another, the ...
11k views

### How can I rotate an object based on another's offset to it?

I have a 3D model of a turret that con rotate around the Y-axis. This turret has a cannon that is significantly off the center of the object. I want the cannon, not the turret, to aim at a specified ...
• 429
26k views

### How can I move a sprite in the direction it is facing?

I'm using Java/Slick 2D. I'm trying to use the mouse to rotate the sprite and the arrow keys to move the sprite. I can get the sprite to rotate no problem, but I cannot get it to move in the direction ...
• 315
1 vote
1k views

### Object scales strangely when setting y rotation after parenting

I created 3 boxes, then align the three to form some sort of a gate, I set the parent to an empty object so that I can easily move it. And I add box collider inside the gate. When I try to rotate it ...
• 125
1k views

### Problem finding correct value for Yaw

I use an Arduino and a 9dof sensor ( gyroscope, accelerometer and magnetometer ) and i'm trying to use the pitch, roll and yaw that the sensor gives me to rotate an object in unity. I managed to ...
• 185
3k views

### Quaternion rotation problems [duplicate]

I want to rotate my model and I have X and Y rotations. Here is my code: ...
• 157
1k views

### How to change LookRotation so the y axis will always face the target position

I have this script that points a missile's z+ axis at its target: ...
• 253
12k views

### How to keep my Quaternion-using FPS camera from tilting and messing up?

I am using an FPS-like camera, and it uses quaternions. But, whenever I try looking up and then sideways, it tilts, and sometimes it can turn upside down. How can I fix this?
• 371
23k views

### How to rotate an object around world aligned axes?

I have a Vector3 which has an euler angle for each axis. Usually, when I want to create a rotation matrix I will use functions such as D3DXMatrixRotationX passing the respective angle from my ...
• 1,001
2k views

### How do I make an object face the mouse position, but only on one plane?

I want a game object to turn and look towards where the mouse was clicked (in world space). It works well when considering all 3 dimensions, but I really only care for the plane formed by the ...
• 829
13k views

### Converting a quaternion in a right to left handed coordinate system [duplicate]

I have a quaternion from an IMU that id like to represent in unity. The issue is that the sensor uses a right handed coordinate system while unity uses a left handed coordinate system. In order to ...
• 1,441
5k views

### Convert quaternion to a different coordinate system

OSVR has a right-handed system: x is right, y is up, z is near. I need to convert orientation data from a sensor in OSVR to a different right-handed system in which x is forward, y is left, and z is ...
• 121
1 vote
8k views

### How should I rotate vertices around the origin on the CPU?

I have tried using glm::rotate and such. glm::translate works fine, but rotate doesn't work (if I rotate before/after a translation). Here is my current setup: ...
40k views

### How can I rotate pixel art sprites without the aesthetics getting ruined?

I'm right now in front of a huge "Game Design" question. I'm making a pixel-art-ish game and using bilinear interpolation could solve lots of animation-issues. On the other hand, its not a "pixel-game"...
• 1,460
6k views

### Arbitrary Rotation about a Sphere

I'm coding a mechanic which allows a user to move around the surface of a sphere. The position on the sphere is currently stored as theta and ...
• 233
2k views

### Arcball Problems with UDK

I'm trying to re-create an arcball example from a Nehe, where an object can be rotated in a more realistic way while floating in the air (in my game the object is attached to the player at a distance ...
• 41
71k views

### Rotate an object smoothly on the Y axis in Unity

I am attempting a simple script to swing a door open in Unity. This requires a smooth rotation of 90 degrees around the Y axis. I have seen that one way to do this is using Unity's Quanternion ...
• 271
1 vote
1k views

### how to get if a rotation/position has been completed?

I've done an if / else with the final position / rotation plus they never complete, how can I check this? stays like this https://i.sstatic.net/3ADqz.gif ...
• 21
570 views

### how do I move an object based on rotation of another object?

This question is related to my other question about camera rotation. I hope its acceptable to ask a second question. I cannot figure out the math of how to calculate moving the camera to stay behind ...
• 223
25k views

### How do I make an entity move in a direction?

I have an Entity instance which is updated every game tick. Let's just assume that entity moves forward constantly. I'd like to be able to give the entity's angle ...
• 583
1k views

### Render 3d object to 2d surface (embedded system)

i am working on an embedded system of a sort, and in some free time i would like to test its drawing capabilities. System in question is ARM Cortex M3 microcontroller attached to EasyMX Stellaris ...
8k views

### Why is my sprite displayed offset from its Box2D body?

I found out about this using a debug renderer. When the game starts, everything is in order. But when a collision happens, the sprite's rotation is way larger than its body. The sprite and body match ...
• 1,768
1k views

### How To Approach 360 Degree Snake

I've recently gotten into XNA and must say I love it. As sort of a hello world game I decided to create the classic game "Snake". The 90 degree version was very simple and easy to implement. But as I ...
36k views

### Unity3D Orbit around orbiting object (transform.RotateAround)

The best way to explain this is I'm attempting to make a small model solar system (not to scale or anything complicated, just simple rotation as a learning exercise). There's a sun, a planet, and that ...
• 185
8k views

### How do I rotate a sprite so that it is 'pointing' in the direction it is moving?

I have a sprite, e.g a missile, heading in a certain direction (using a velocity vector). How do I figure out its how much to rotate it so that it gets drawn 'pointing' in the direction it is heading?...
• 6,126
3k views

### How to Align Gun with Bullets

I have a top-down 2D shooter. I have an image of a player holding a gun, that rotates to face the mouse. Please note that the gun isn't a separate image tethered to the player, but rather part of the ...
• 71
899 views

### How to calculate origin and position of a weapon which should be "in hands"?

I'm currently stuck with my game, which is from the top perspective. I'm currently using these sprites for player: (using the second at the top): And here's what I use for my gun My problem is that ...
• 429
3k views

### Moving a rotated model in XNA

This seems like a simple problem with an equally simple solution that is invisible to me. I have a model that spawns at the origin and looks at my player model wherever it goes. I would like it to ...
5k views

I'm talking about the public void Draw (Texture2D texture, Vector2 position, Nullable sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)...
5k views

### Movement and rotation of bodies in top down game

We are developing a 2D top down game with libgdx using the included box2d as physics engine. We don't want our bodies to accelerate but to instantly move with the wanted velocity. The bodies are ...
• 133
6k views

### Cocos2d rotating sprite while moving with CCBezierBy

I've done my moving actions which consists of sequences of CCBezierBy. However I would like the sprite to rotate by following the direction of the movement (like an airplane). How sould I do this with ...
• 425
5k views

### per pixel based collision detection

I was wondering if anyone had any ideas on how to get per pixel collision detection for the android. I saw that the andEngine has great collision detection on rotation as well but couldn't see where ...
• 87
2k views

### Project rotated matrix to isometric coordinate

I have a group of soldiers, and each has a vector describing their position in the squad. When the group rotates, I do this math to calculate the desired position of each soldier. ...
• 23
737 views

### Inverting matrix then decomposing gives different quaternion than decomposing then inverting the quat

I'm getting different signs when I convert a matrix to quaternion and invert that, versus when I invert a matrix and then get the quaternion from it: ...
• 1,462
770 views

### Is there any way to keep the applied torques in the old planes, even if the ship's local plane has rotated?

I'm trying to make a space shooter game in Unity3D with realistic spaceship physics. I have a problem with correct rotations. When I apply torque in global coords system it will always apply them in ...
• 123
6k views

### Make camera follow and rotate with player without childing it

I want to have a camera, that follow the player, without childing it to the player object. So far I have this one line, that follows the player, but does not rotate with it (meaning the camera should ...
• 341
1 vote
4k views

### How to rotate to a target position over time

I know how to do rotations to vectors, but how do I rotate over time? For instance say I made a function RotateTo(vec2 iPosition, float iTime); so it rotates to ...
• 21
1 vote
4k views

### Rotating towards a target in top-down 2D game

I use the following code to rotate a transform towards another. And it's working fine. However, I want to lerp it over time period. ...
413 views

### Keep Mini map static after rotating / zooming with camera

Hi I am making a 2D game, where the Camera is able to rotate / zoom in or out on the camera focus (the player usually). However my game also contains a mini-map, and so far whenever I have to rotate ...
196 views

### How to Work With Arbitrarily Oriented Vectors

I'm brushing up for a pending game jam and just for kicks I thought I'd let the gravity in my 2D platformer push at an arbitrary angle. Normally gravity points downward (3 PI / 2), but if I wanted it ...
• 157