No announcement yet.

2D Top down rotation interpolation

  • Filter
  • Time
  • Show
Clear All
new posts

    2D Top down rotation interpolation

    I'm working on a top down 2d shooter prototype.

    The character should aim at the cursor. I eventually got it to work like this:
    Click image for larger version

Name:	Screenshot 2017-05-06 01.16.58.png
Views:	1
Size:	129.7 KB
ID:	1217806

    I now tried to interpolate in order to get a smoother rotation and also implement some sort of "turn speed" so you can't flick 180° instantly.

    I tried RInterpTo and use the current rotation, but it keeps doing weird rotations..
    I then tried to just use the Pitch of the current rotation, didn't work either..

    I also tried to save the currentAngle in a variable so I could use it for interpolation in the next tick. That did work to some point, but when I rotate over +-180°, the character turns all the way around instead..

    The thing is, I don't want to use hit result, I'd like to stick to the mouse's X and Y coordinates. I tried doing that with a vector instead of angles, which I thought would be easier, but I didn't get it to work. I really want it to rotate solely on the Y axis (cuz duh, it's top down 2D..)

    Any advice?

    Big thanks in advance