Tag Info

Hot answers tagged

3

This is a late response, but I figured this question illustrates a common problem that many people are likely to run into and that deserves an answer. Quaternion rotation uses half the angle you want to rotate by. Since you (in this example case) are rotating by 90 degrees, the quaternion needs to calculate the sine and cosine of 45 degrees, both of which ...


1

I suggest moving the target slowly rather than the angle. Try this: Vector2 Target; // Interp is a value between 0 and 1. When 0, the target never moves. // When 1, the target moves instantaneously. Intermediate values cause the target // to move at different rates. void UpdateTarget(float interp) { Target = interp * Mouse.Position + (1 - interp) * ...


1

I think any linear function would be fine for this. You can keep two variables one for your spaceship's current angle spaceshipAngle = Math.PI*k, and one for the current angle that the user inputs with his cursor cursorAngle = Math.PI*p. And what you do is if (Math.Abs(Math.PI*k, Math.PI*p) < Math.PI) { if (Math.PI*k < Math.PI*p) k += ...


1

Your tilt line is stomping over whatever rotation the drone had and applying a new one. Just like writing: variable_a = 42; will replace whatever value was in variable_a before, the same happens with rotations, unless you use some type of combining operator like multiplication or Lerp. To fix this, you can build a rotation that takes both inputs into ...


1

If your problem is simply to deal with the fact that -10, 350, and 710 are all equivalent angles, that you may potentially get any desired angle, and that you never want to make a total rotation over 180 degrees, then: double Distance = DesiredAngle - CurrentAngle; // Let's bring Distance to its closest equivalent in the [-180..180] degrees range while ...



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