Tag Info

New answers tagged

3

This problem is called Forward Kinematics. To solve this problem in general, I recommend creating what is called a Kinematic Chain, or Kinematic Tree. To do this, you will need knowledge of a 2D rotation matrix, or transformation matrix. A 2D 3x3 transformation matrix is defined as: H = [xx, xy, tx; yx, yy, ty; 0, 0, 1]; In this case, [xx, ...


0

For each part, it need to have an offset to the hero location. Eg, +20, +20. Its correct position when hero rotation is r is heroPosition.x + rotated(offsetX, r) and same for y. See http://en.wikipedia.org/wiki/Rotation_matrix for more info.


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


0

Based on user55565's answer, I did some reading on rotation matrices and took his main idea and did some paper sketching. In the end I came up with the class below, which works. The basic idea is to reference the position of the square by its center coordinates. When you want to rotate it, you follow these steps: Calculate the current(before the ...


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

Try sprite.setOriginCenter(); This should help


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


0

Your code is a little strange. If you want to rotate around the Y axis, then you change the X and Z coords, but you're altering Y and Z. This code rotates smoothly around Y: function rotateCameraY(radiansIncrement) { var x = _camera.position.x; var y = _camera.position.y; var z = _camera.position.z; var signx = x > 0 ? 1 : -1; // get current radians ...


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



Top 50 recent answers are included