Tag Info

Hot answers tagged

1

You need to move each part to 0,0 then rotate them, then move them back. Without doing this they just rotate around 20 units fron your character


1

Im not sure this works 100% but here is an idea to get you started. Let your square have x,y as center and r as its current rotation value. Let dx and dy be the displacement from center to one corner of the square when r is 0; On rotate-moving the square on the said corner: First get the corner's position: cx = x + rotated(dx, r); cy = y + rotated(dy, ...


1

A normalized direction is a point on the unit sphere, so you need 2 angles. I assume you have a coordinate system where Y is up. Your two variables are phi (0 <= phi <= pi) and theta (0 <= theta <= 2pi). You obtain the normalized direction vector as follows: dir.x = cos(theta)*sin(phi) dir.y = cos(phi) dir.z = sin(theta)*sin(phi) Source for ...


1

This may not be the answer but, instead of using sprite.rotate(float angle); use: sprite.setRotation(float angle); Hope this helps! :D


1

Assuming your camera have a independent forward vector that always points from position of camera to the character; Suppose if you want to rotate the camera N radians in the local Y axis (character up) and maintains the same distance to target after the rotation: quat = axisAngle(target.up, radian); camera.forward = rotateByQuat(camera.forward, quat); ...


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 ...


1

It depends on the coordinate system you're working in. In a right-handed coordinate system (eg. x right, y up, z points toward the viewer), the right-hand rule applies, as mklingen describes in the existing answer. In a left-handed coordinate system (eg. x right, y up, z points away from the viewer), the left-hand rule applies - you point your left thumb ...


1

Quaternions are not axis/rotation vectors. That's just not how they work. They do encode an axis/rotation, but not in the way you describe. Check out the equation from wikipedia: Given an axis [a_x, a_y, a_z] and angle theta, q = [a_x * sin(theta / 2), a_y * sin(theta / 2), a_z * sin(theta / 2), cos(theta / 2)] That said, if you do have an axis/rotation ...


1

Try sprite.setOriginCenter(); This should help



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