# Questions tagged [rotation]

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

1,183 questions
Filter by
Sorted by
Tagged with
2k views

### How do I prevent camera jitter when rotating the player?

This is a problem that seems to have no reasonable answer anywhere around, yet is a commonly needed aspect of developing game mechanics. Context I'm developing a traditional 3rd person character ...
69 views

### Aligning vector by rotation around non-orthogonal axis

This is almost more a geometry/mathematics question than a game dev one, but I think I'll have a better chance actually understanding the answer if I ask here. Rather than try to explain it- because ...
253 views

### Rotate Object Smoothly When Dragging

I want to make a 3d object rotate smoothly when being dragged in a ui in Unity. My stuff currently works but I just can’t get it to rotate smoothly, I can only make it rotate instantly which looks bad....
36 views

### Rotate UVs in shader and contains result into quad with repeat edge pixels

I ask for help - I need to rotate the UV scan inside the quad by a certain angle (set by a parameter) so that the result is embedded in the original UV, and the missing areas are repeat edge pixels. ...
30 views

### Follow camera is not turning when the followed object turns

I need a camera follow script to chase a moving ball. I've attached the script below to my camera, but when the ball turns left and right the camera does not turn ...
1 vote
126 views

### How to set world rotation directly in Stride?

I just started looking into Stride as a replacement for Unity, and I'm trying to rewrite some scripts. My question is: How do you set the world rotation of a transform component? In other words, what ...
1k views

### How to rotate NavMeshAgent toward its movement direction?

I'm working on a 2D game in XY plane. I've created enemies using NavMeshAgent and I've gave my agents way pints to move between them. The problem is that I don't know how to rotate them in the ...
126 views

### Correct order on accumulating rotations

Suppose I have an Arcball camera that rotates up/down and sideways based on mouse input. After doing some research, I discovered that the correct way of calculating the new orientation is to do it the ...
150 views

### Finding loss of angle and length due to rotation

I'm working on a targeting system for my 2d game. But I want to see the object in isometric perspective. My calculation is correct for 2d objects but it doesn't work for rotated in x axis objects. I ...
2k views

### Xbox thumbstick used to rotate sprite, basic formula makes it "stick" or feel "sticky" at 90 degree intervals! How do you get smooth rotation?

I am using a very basic formula to calculate what angle my sprite (spaceship for example) should be facing based on the Xbox controller thumbstick i.e. you use the thumbstick to rotate the ship. In ...
59 views

### Quarternion rotation flattening cube

I am trying to rotate a cube using a quaternion matrix with WGPU. However, whenever I try to rotate it, I end up with I am using the matrix from https://en.wikipedia.org/wiki/...
299 views

### How to make enemy turn to face the player while attacking?

I need help making this code work. It is made for the enemy AI to move and patrol, chase the player and attack the player. The problem is when it starts to attack the player, then the player can move ...
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 ...
26 views

### Rotate the parent object so that the child object points to the cursor 2D [duplicate]

I have an arm that has a pivot point on it. I want to rotate the arm so that the barrel of the gun points to the cursor. How do I calculate the angle of rotation for the arm? I'm not very good at math ...
80 views

### How to keep an object that rotates around another at the same height when the radius changes?

In my game, I have one object that rotates around another using transform.RotateAround, and I need to change the radius of its orbit. The behavior now is that the ...
5k views

### Rotate from Current Rotation to Another using Angular Velocity

I am attempting to calculate an angular velocity that will get me from the current gameObject.transform.rotation to a given Quaternion rotation using angular velocity. I've tried several methods but ...
1 vote
358 views

### Using both look_at and flip_h in Godot

I am trying to have a player running in a side scroller platformer with its arms independent from its body, so that the arms can follow the mouse (to aim). The issue is that when the character goes to ...
144 views

### Where is the illusion of a moving camera perspective coming from in this rotatable cube model?

Just for fun, I had been attempting to build a model cube in vanilla JS that can be moved and/or rotated. What I was going for was the simplest possible representation (so, no adjusting for ...
61 views

### Rotating around 3D cube Camera Controller for Unity

I am Unity game developer with more than 2 years experience. I am working in a personal project, a mobile game for Android in Unity. I am trying to make a camera controller for a 3D Cube Game in Unity....
704 views

### Rotating a sphere so point lines up with the camera

I'm trying to make a world map in Unity that contains a rotating globe with landing sites on the perimeter. What I want is that when a player clicks on the landing site the globe rotates so that the ...
116 views

### Inertia Tensor Relative to Center of Mass vs Inertia Tensor in Body Coordinates

If I have the inertia tensor relative to the center of mass, is that the same as the inertia tensor in body coordinates? If no, can you please explain the difference and how do I numerically calculate ...
97 views

### Smartphone tilt calculation when using gyroscope in Unity (smartphone moving problem)

I have been trying for several days now to set up the correct behavior of the gyroscope in Unity. I want to make it so that when the smartphone is tilted, the object tilts along the z-axis. I found ...
129 views

### When to use InverseTransformDirection in Unity

I want to know when to use InverseTransformDirection. Unity documentation says : "Transforms a direction from world space to local space". Honestly, it is not clear for me. I came across ...
149 views

### How to rotate a plane about its origin?

I am trying to figure out how to rotate a plane about its origin in 3D space. Here is the last iteration of the code I am working with; the plane does not move. ...
1 vote
39 views

### How to throw an object using a rotating arm controlled by the player?

Apologies in advance for my lack of knowledge, I am very new to 3D My goal is relatively simple. The player controls an arm and uses the mouse to rotate it around a point. They can hold the mouse ...
117 views

### Choose rotation facing direction

I am rotating a gameobject in Unity so it always faces another gameobject. However I want to be able to decide which side is going to face the target. I want to be able to change the facing point to ...
215 views

### Why can't I edit the rotation property in prefab mode so that rotation changes apply to all instances?

I am learning using the Explore Unity Course. In the picture you can see I've instantiated many hats from the same prefab. I want to rotate the hat in prefab mode so that the change will apply to all ...
3k views

### How to set rotation of object using angle between two points?

I have a LineRenderer that draws a line between two points, Vector3 startPos and Vector3 endPos. How can I get the angle between these points, and apply it to an objects transform rotation, so that it ...
155 views

### 3D First person Rotate Character Unity

I'm facing the problem that my chacter is spinning around itself when I try to move, that's because Im trying to make my player move in the direction of the camera, but when I move it keeps rotating ...
27 views

### How to make Cardial Directions relative to the camera

Lets suppose tha my movement method my W goes towards north(just figuretvly) and my E goes towards east, If I rotate my camera to east I want my W to insted goes to north, goes towards east and my E ...
124 views

### How do I make my player rotate in the current direction of my camera in Unity using C#?

I have a player with third and first person camera, I want to make my player move in the direction that my camera is looking at when I hold the right mouse in third person and move(Like my player is ...
45 views

### Orient a player mid-air to their predicted landing orientation in Unity?

Ever played Skate 3? When dropping into a ramp, or if you're midair, your player's up direction aligns to the normal of the surface you're about to land on, while respecting the player's forward ...
5k views

### World position into local position

I want to understand how I can convert world position of an object into local position. Especially how to deal with a rotation of objects. I'm testing transform.InverseTransform(...) methods. When ...
2k views

### Rotate Rigidbody to face away from camera with AddTorque

I have a camera that rotates around an object with "Look At" . I want the object to rotate to face the direction the camera is pointing (Camera.main.transform.forward) using AddTorque, but I can't ...
1 vote
166 views

### How do you rotate an object that uses a quaternion to represent orientation in 3D from a 3 vector input with values from a gamepad?

I'm using unity3d to create a six-degree of freedom flying game. The game takes in input from a standard dual-stick gamepad (like the Logitech f310). In unity each of the gamepad's joystick's axes are ...
1 vote
583 views

### Orbit and control distance from object in 3D

I'm stumped on a key part of my game project, built in Godot 3.5.2. I'm trying to have my player character be able to rotate around an object using A and D, as well as get closer and farther from it ...
182 views

### Rotating on Z axis with easing

I am stuck with rotating a GameObject on the Z axis with easing. I want to achieve an effect like in this game: Here, the ring of targets starts rotating periodically. It starts slower, than ...
142 views

### how to rotate my character along the y axis when character is aligned with a slope

I have a capulse character Im moving around in my 3d Game, I usually rotate the character using this line of code: ...
1k views

### How to clamp rotation on a specific axis?

I want to rotate an object based on mouse delta but I am unable to clamp it because I only want it to turn so far on a specific axis. ...
2k views

### How to rotate a mesh in shader graph?

I want to rotate a mesh in a way that the Z axis arrow always points towards the camera. For a script I would do something like this: ...
182 views

### How to rotate a player to orient their up with a landing normal?

I'm making a skateboarding prototype in Unity, and like in skate 3, I'd like the player to sort of "align" gradually to their predicted landing slope. I've written the code that gets the ...
189 views

### Trying to rotate a 2D kinematic object along its Z axis when its Y rotation is exactly 180 degrees causes massive rotation swings

I have some code that allows an object to be rotated back and forth on its Z axis, but am having issues when the object has an initial Y rotation of exactly 180 degrees while also trying to rotate it ...
136 views

### glm::eulerAngles gives unexpected output for quaternion

I used the euler->mat4->quat to give the right result, but euler->quat gives the wrong result - is there something I did wrong? ...
1 vote
459 views

### How to rotate 2D image in 3D space using a quaternion

I am trying to rotate a flat 2D image around a 2D origin in 3D space. The problem I am having is that the image becomes stretched after the rotation. I am using the WGSL from this tutorial, but with ...
9k views

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

I use LookRotation() in order for an object to look at another, but since I'm using 2D I would like to make the axis looking/facing the target to be X instead of Z. I have the code below currently: <...
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: ...
73 views

### Align two meshes given 2 faces

I have two meshes (A and B) and I know that a triangle in A has the same size and same angles as a triangle in B. For simplicity, suppose A is an octahedron and B is a tetrahedron. And suppose the ...
33k views

### How to rotate an image on an HTML5 canvas, without rotating the whole canvas?

I want to rotate single sprites on the canvas without rotating the whole canvas. I also don't want to create a new canvas for each object I have. Also, it would be interesting to know which solution ...
78 views

### Rotation is happening in reverse when the cube is upside down

I am writing this functionality in DirectX to rotate cube using the mouse. Now the functionality is working perfectly fine when the cube is sitting straight, but mouse functionality is reversed when ...
1 vote
24 views

### I have a wind simulation in Unity, and i need to rotate an arrow to show the wind direction [duplicate]

I have this code that creates random vectors, which are used in the AddForce to push rigid bodies around. ...