The 2024 Developer Survey results are live! See the results

# Questions tagged [rotation]

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

1,190 questions
Filter by
Sorted by
Tagged with
337 views

### Quaternions distorting object in Metal

I've been trying to get rotations with quaternions to work for a while now, and I feel I am very close to it actually working but I just can't get it to work. I do not have a view matrix yet and am ...
602 views

### How to rotate a 3D object based on stick Input and the normal of the ground's surface?

I am making a game where I want to view an object from any angle and use an analog stick to rotate it according to this input and the surface the object is currently resting on. Here's a visualization ...
171 views

### How to make a sprite face the mouse while remaining upright, without negative scale?

In the game I'm creating I have a sprite that needs to constantly be facing the mouse, but the sprite also always needs to be facing "up". Because of the Polygon Collider 2D and Shadow ...
1 vote
1k views

### Pixelart loses quality when rotated in unity

Sorry, still fairly new to the game here but my pixel art gets little ridges on it when I rotate it in unity. I'd like the pixels to rotate all together. Is this just because I need to make my pixels &...
1 vote
581 views

### How to correctly rotate object using clamping and euler angles?

I've a player (a space-ship ;) that can rotate from -x to +x value (so clamped). So, before apply rtoation i check it: ...
• 437
62 views

### Can you interpolate statelessly?

I was just wondering if it's possible to to a linear interpolation between two rotations without maintaining any kind of state. What I mean is let's say I have a loop function where all my code is ...
• 75
1k views

### Local rotation towards world point, with axis other than forward vector

I have a turret transform which is a child of weapon game object. Which in itself is a child of player object. I want to rotate this turret towards a world point (Raycasthit.point of a ray going ...
1 vote
73 views

### Trigonometry to move an arm around axis in 3D space

Hello I have a question about rotating a Rod hinged to a fixed point (so it swings all around), and targets. short form, I would like to know how to find a rotation that would point my rod (while ...
• 37
1 vote
930 views

### Shooting from Gun in LibGDX

I'm trying to shoot a bullet from the tip of a gun. This gun is a Sprite object and it is constantly being rotated to point towards the mouse. The issue is that the point to shoot the bullet from is ...
529 views

### What math function represents Minecraft bow angle/height?

I am working on a mod in Minecraft Forge/MCP using Java. Aiming a bow is controlled by your head pitch and yaw rotation. Right now I have a math function that automatically looks at the target. But I ...
• 75
213 views

### Get Angle offset [duplicate]

I'm working on a game where the input is done via a joystick. Normally, one would snap the players rotation to the angle that the joystick is pointing, but for my game's purpose, I have to lerp to the ...
• 25
663 views

### Rotating only 2 axes of rotation quaternion to "point" in a direction

Note: I am using the Unity DOTS ECS framework, which contains less maths functions, but I can probably implement the same functions from standard unity if the code is public. This question is not ...
584 views

### How to gradually interpolate smoothly between two yaw rotations in Minecraft MCP/Forge?

I am coding a custom client for Minecraft using MCP. (Please no hate, I'm not making a hacked client!) I have two variables currentYaw which is the current yaw ...
• 75
1 vote
972 views

### Limit rotation/direction of two axes with seperate values (Vector3)

Issue I'm trying to create a vector pointing in a direction towards a target, and then using that vector rotate a child transform to face the target while limiting the rotation on the X and Y axis, ...
1 vote
207 views

### Forward movement while rotating lead to flickering

I'm trying to make a ship move forward while also turning, but when I start to play, the ship flickers when it tries to move and turn at the same time. (as comments suggested, I added other code for ...
• 173
369 views

### Parent object does not rotate on its own axis with its children. How do I fix it?

My parent object components: Rigidbody2D and the script I shared below. Children(Head, Body, Arm, Backpack...): There is only collider. There is no rigidbody2D. (I want the parent object to use the ...
• 13
1 vote
196 views

### Player rotation recalculation causes jittering on edges

When my player walks around a circular planet everything works well, but when my planet is a shape like a cube or a dodecahedron, even with smoothed edges, my character jitters if I walk slowly on the ...
343 views

### Rotation matrix for a model where the forward axis is not +X

I'm trying to convert a normalized unit vector, representing an entity heading, into a rotation matrix for rendering. The problem is that I'm using an (apparently) unusual forward vector for my ...
• 604
182 views

### Keeping two triangles with different scale attached during rotation

I'm making a simple Lunar Lander clone. The ship is a triangle, and I'm trying to draw the exhaust fumes of the ship. I'm wondering how to draw the exhaust so it's always relative to the ship. I'm ...
• 3
1 vote
197 views

### Simulating a rocket out of control in Box2D

In the void of space, a spaceship releases a rectangle shaped space-torpedo. In half a second, it starts its rocket engine and goes straight until something get in its way, and then boom! The code ...
• 376
106 views

### 3D AxisAngle spins at 180 degrees

I am using the Axis Angle technique on objects so that they are oriented away from a planet surface like in Super Mario Galaxy. I am using two unit vectors [0,1,0] and a normal vector from the planet. ...
141 views

### Unity Camera resets rotation instead of using existing values

I'm working on a generic camera rig using mouse inputs, kind of like an RTS camera but it will be used to look at models with as a sort of turntable viewer. The issue I am having is that when I rotate ...
• 125
312 views

### Why my player can suddenly fly?

I'm working in a project with Unity 2d where player walks on a small planet. I try to use some code from youtube tutorial to apply gravity to my planet.This code consists of two parts, Attractable and ...
• 88
1 vote
1k views

### Reorientation when rotating Transforms around another Transform without parenting

The functionality I am trying to implement, consists of rotating one Transform and appling this rotation to other relevant Transforms in the scene. To make it a bit more clear: I have several objects ...
188 views

### How to calculate local orientation of child relative to parent from only global positions?

I am trying visualize a human finger's pose with a 3D model in Three.js. The 3D model is composed of 3 bones that represent the proximal, middle, and distal bones of the human finger, connected in ...
2k views

### Unity 3D - Make character look at mouse with New input system/Character Controller

So I've been trying to make a top down game with the new input system. Been trying to make the character rotate and look at the mouse's position. The player moves on the x and z axis, with the camera ...
1 vote
737 views

### Pygame 2D : rotation around center not working properly

here is the code I use to rotate an image around its center: ...
• 226
2k views

### Creating a custom camera in Godot

Allow me to start with what I'm trying to achieve - there might be an easier way to do this and I'm just overcomplicating things. I'm trying to implement a camera, that will be able to rotate around a ...
• 309
2k views

### How to set transform.up without locking the y-axis?

I'm trying to make an object's transform.up to a normal of the raycastHit point. I tried using this line of code: ...
• 115
2k views

### What happens if first we scale a rotation matrix and then multiply it with an object?

This question has been bothering me lately. I know the correct order to scale, rotate and transform a matrix but the question I have is very different. What if we first scale our rotation matrix by ...
149 views

### Find the vector orthogonal to a quaternion?

Apologies if the title doesn't quite make sense, it's been a long time since I did any 3D stuff. I would like to be able to pan my camera up and down with the arrow keys. The camera's rotation is ...
284 views

### 2D - How to make a gun muzzle aim at the mouse when the rotation pivot isn't on the muzzle?

I'm making a simple 2D shooter game in pygame and I've come across an issue when making the character aim its gun at the mouse. To make the gun aim up and down, I've set it so that the gun uses the ...
208 views

...
• 1,757
3k views

### Get a Vector2 Based on Object Rotation in Unity

I feel like there is an obvious answer to this but I can't find it. Is there a function in unity that gives you a Vector2 (or 3) based on the rotation of an object. for example: z rotation = 0 ---> ...
95 views

### Calculate how many degrees a physical device is off centre (offset) given X, Y, Z

Let's say I have a physical device that I can rotate with my hands and receive X Y Z coordinates of that device. What I need to calculate is the offset - how far is the pendulum of gravity straight ...
• 3
46 views

### How to I make MOUSEY look up

I have MOUSEX worked out perfectly, it moves on the X axis, but when I add the Y axis, I can't use the MOUSEX axis. ...
899 views

### Rotating 3D Object Towards Swipe Direction

I have a character that has a constant speed, and I want to be able to change its direction with swipe gestures, The exact same mechanism implemented here. I managed to do that for movement only, ...
1 vote
301 views

### Need help getting an objects orientation / all my OpenGL rotations are reversed

I'm using OpenGL on Ubuntu Linux with the Eclipse IDE and the GCC compiler. I am bringing blender models into a homemade renderer/game engine. I parse a text file containing object descriptions to ...
• 11
2k views

### How do i easily clamp my cameras rotation when using transform.rotate()

I'm making a fps controller, and I'm trying to clamp my cameras x rotation. Here's my code so far: ...
• 500
992 views

### How does Unity know where the character is facing?

I just learned Quaternion.LookRotation and it's used for rotating an object. I used it to face my character in the direction where it's moving, but I couldn't ...
27 views

### Rotating with a preferred direction [duplicate]

I do a RayCast to the terrain and then use the RaycastHit.normal to plant flags. I would like to have the flags to point up with the normal, but have them all face the same direction. As seen in the ...
217 views

### What is the relationship between gimbals and Euler angles?

Through reading a lot of articles, I understand what gimbals are (at least I think so). And I know that Euler angles follow the rules of gimbals, but why? Why do Euler angles comply with the rules of ...
• 1
1 vote
93 views

### How to best simulate the space in a boxing game to account for footwork and angles?

When trying to prototype a (top-down, so far) boxing simulation I've run into a huge roadblock with trying to set the space in which the boxers will fight, because it's important for the fighters' ...
• 13
160 views

### Head rotation according to weapon sight

I have a 2D game and I'm working on head rotation with my newbie coding skills. My Player has child sprite object called DefaultPistol (which is the whole arm and ...
1k views

### Rotating fps rigid body on the Y axis

I'm currently attempting to make a first person character using a rigid body. I am aware that the character controller exists, but I believe my game will be very physics based so it's better if my ...
• 500
1 vote
75 views

### How to create a joint, where the rotation of one object is relative to the other?

I would like to create a top down view scene, with one rectangle (top) is on top of an other (base). There is a joint, where ...
• 277
172 views

### how can I rotate a tetrahedron's vertices so that it's pointing straight up?

I am trying to render an Equilateral triangle in 3D, and I came across this answer: https://math.stackexchange.com/a/562895/15497 So based off of that, I made my vertex points: ...
• 209
395 views

...
• 1,757