Character orientation inconsistent when walking upwards diagonally


Xilexio
  • Pending

tl;dr: You compare exactly floating points, resulting in weird behavior.

When the player goes upwards diagonally, the character sprite is directed either upwards or to the left/right. This is inconsistent. More specifically, if (inst is the player) (inst.Transform:GetRotation() + TheCamera:GetHeadingTarget() + 360) % 360 falls between 135 and 225, it shows facing upwards, if inst.Transform:GetRotation() is non-negative. If it is negative, it faces upwards if (360 - inst.Transform:GetRotation() + TheCamera:GetHeadingTarget() + 360) % 360 falls between 135 and 225. The problem is that while camera rotation is exactly 0, 45, 90, etc., the player rotation is always off by a fraction of a degree.

It was important for me, because I am doing a mod, where I want the beard to appear only if the sprites are in the upwards position, so I need to detect when the player is shown going upwards relatively to the camera.


Steps to Reproduce
0. Make sure camera rotation is 0. 1. Press W+D to run diagonally. Character will be shown running upwards. 2. Press Q 4 times to rotate the camera to 180. 3. Press W+D to run diagonally. Character will be shown running rightwards. 4. Same with W+A and different camera rotations.


User Feedback


There are no comments to display.



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