Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Struggling with some rotations  (Read 2271 times)

0 Members and 1 Guest are viewing this topic.

dbear

  • Newbie
  • *
  • Posts: 1
    • View Profile
Struggling with some rotations
« on: April 23, 2021, 11:07:08 pm »
I'm trying to figure out how to move and rotate a bullet projectile from my starting location to an ending location. For example:

I have a function called HomingMissle, which takes the inputs of a target Vector2f, where I'm aiming, my players current position as a vector2f, a current velocity, a maximum rotation speed and of course, delta time. I've essentially got the basic idea setup.

I'm subtracting the target from my current position to get the direction. Then I'm using atan2(direction.y, direction.x) to get the angle in radians. However, I'm struggling to limit the amount of rotations that can be performed on tick. I only want to rotate a partial amount of the entire rotation, up to a limit based on the maximum_rotation input variable.

Any ideas?

Thanks,
Brandon

LucasM

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Re: Struggling with some rotations
« Reply #1 on: April 24, 2021, 04:16:25 am »
Try using a rotational speed factor.  Change in rotation = rotationalSpeed * deltaTick towards the new rotation angle.  Just basic.  Could get fancy with inertias and acceleration and that but I think that would be overkill.

 

anything