Sign in to follow this  
Yazaa

Making a sprite turn to an angle by a constant degree each tick

Recommended Posts

Hello!

I am new to phaser and I'm stuck at really simple thing. I have a sprite which i want to rotate towards mouse. I tried using various functions like getShortestAngle (since when it comes to 180 degrees, it picks the angle around it) with custom math with little to no success but I also stumbled upon another function.

The function is called rotateToAngle and it does what i want, but it glitches when going through angle 0 and PI (0 and 180 degrees). It instantly locks onto the target without the step then and it proceeds to work normally.

Also a minor notice: It's third parameter is called lerp, but it isn't interpolated angle change but static change by a step.

 

I couldn't find any function on the net (except I know Construct 2 has such function and it's really useful). It took me more time than I'd like to say and I'm getting desperate with having that angle function (I made a challenge for myself to create a simple game in phaser in 1 week and I am stuck on such feature!).

I could provide video if the problem isn't described properly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.