Howdy friends! In the following piece of code, I’m trying to multiply the player’s acceleration by the sign of the normal of the ground they are standing on. For example, if they’re on a slope facing right, the x normal should be positive and the z normal should be zero, and if they’re standing on a slope facing down, the z normal should be negative (I think) and the x normal should be zero. I’m trying to get the sign of the normal values only, not their actual value because that’s a pretty small number. I tried doing this by dividing the normal values by their absolute self to turn them into either positive or negative one and then multiplying the acceleration number by that, but the problem is, if the normal x or z is equal to 0, the acceleration becomes NaN because dividing by zero is illegal. Is there a way I could get the sign of my normals without dividing by zero? Thank you!
Even though the x normal is 0, the sign function still returns a positive 1, as seen in the print statement at the bottom. Is there a reason for this?
It only returns the sign of zero being positive at the frame where the player steps from a flat surface to a slope, it doesn’t do it if I jump off a flat surface and land on a slope.
I should also add that, in situations where I step onto a north facing slope, I get a -1 as the sign of my normal x. It also says the normal x is -0. What makes a zero negative and how do I prevent this?