Tag Info

New answers tagged

0

Gimbal lock is the answer, avoid using euler angles even converting to and from quaternion, use multiplication by quaternion created from angle axis. Unity3d has same problem when rotating around ox axis: transform.eulerAngles += new Vector3(5,0,0); //problem


0

I think you are misinterpretting the result of setting the origin to (0.5f, 1). I did the same thing, and I got the expected results. Here's a modified version of the code I ran at this answer: Color[] colors = new Color[] { Color.White }; texture = new Texture2D(GraphicsDevice, 1, 1); texture.SetData<Color>(colors); spriteBatch.Draw(texture, new ...


0

As Martin Sojka notes, rotations are simpler if you convert to a different coordinate system, perform the rotation, then convert back. I use a different coordinate system than Martin does, labeled x,y,z. There's no wobble in this system, and it's useful for lots of hex algorithms. In this system you can rotate the hex around 0,0,0 by “rotating” the ...


2

Where's deltaMouse coming from? If the API you're using is giving you translation units like pixels or centimeters, you shouldn't scale by deltaTime. Moving your mouse 1 cm should rotate the camera by, say, 15 degrees, regardless of how many frames or how long it took to move that 1 cm.


1

I don't know about the rotation part but for the mapping input to rotation you can do the following: (this doesn't go in code) add 32768 to your input getting a value 0-65535 from here you can get your multiplier which is 90/65535 = 0.00137 then to get your rotation distance you can simply multiply your input by your multiplier (this goes in code) ...


3

You can extract the translation by removing the top three elements of the fourth column, (1,4), (2,4) and (3,4); You can determine the scale by finding the determinant of the top-left 3x3 elements. The determinant of a plain rotation matrix is 1, so any value above or below that is the scale factor. Note that this is only true for uniform scale; per-axis ...


1

Something i forgot to include was the fact the camera was moving with the ships. When I made the Camera stationary it seamed to work perfectly, so i simply created another camera and kept it at Vector3(0,30,0) and used it to track the mouse instead. Changing the code slightly to be: public static Quaternion RotateToMouse(this Ship ship, Transform ...


0

Vector2 Forward = Vector2.Zero; if (keyboardState.IsKeyDown(Keys.Up)) Forward+= Vector2.UnitY; if (keyboardState.IsKeyDown(Keys.Down)) Forward-= Vector2.UnitY; if (keyboardState.IsKeyDown(Keys.Left)) Forward-= Vector2.UnitX; if (keyboardState.IsKeyDown(Keys.Right)) Forward+= Vector2.UnitX; if (forward != Vector2.Zero) { PlayerForward = ...


0

This code works: // Get the current modelview matrix GLKMatrix4 originalMat = self.effect.transform.modelviewMatrix; GLKMatrix4 currMat = self.effect.transform.modelviewMatrix; // Print the original matrix for comparison //NSLog(@"Original Matrix:"); //[self printMatrix:currMat]; // Define the buffer designators GLuint billboardVertexArray; GLuint ...


0

Try setting up a rotation matrix for both sprites. Rotation matrix - Wikipedia Set the point to where you want to rotate. Although to make it an easier point of reference, I would rotate at the point where the bow crosses the arrow. If i knew what language you're programming in I could look up more information to help. If you haven't worked with matrices ...


-1

There isn't enough information to solve this - we have no idea what any of those functions do. Is this custom software? Is it technology from someone else? I don't understand why one even needs a "scale center". It all seems like an overly complicated piece of tech for something so simple. Try setting the rotation centre with the unscaled width/height. ...


4

Since the arrow is rotating around a center point (the same point of the bow), when you draw back on the bow, you need to keep the center point at the same point as the bow, but move the arrow back across it. That way, you're rotating both the bow and arrow around the same point.


5

If the arrow is of different dimensions than the bow the point which it should rotate around should not be its own center but rather the around the same point of rotation the bow rotates around, which might very well be outside the image of the arrow.


1

Usually assign a child to camera is a bad idea. It will work, of course, but can give a little headache in your hierarchy. Try to create a new empty gameobject and assign camera and the weapon to it (even if i dont like that main camera is a child). For your problem, i simply cant get it and your images are not clear (i didn't see anything wrong, remember ...


2

This is somewhat simple. When working with quaternions, to alter the rotation you multiply the current orientation with the change you want to apply. Now there are two ways to to do it: result = orig * change and result = change * orig The nice thing about this is that the one rotates it in the local coordinate system and the other rotates it in the ...



Top 50 recent answers are included