I'm trying to make a 2D platformer with slope physics in unity, so I'm using this code to make the player move at the correct speed on the ground.
velocity.x = Mathf.Sin(groundAngle * Mathf.Deg2Rad) * groundSpeed;`
velocity.y = Mathf.Cos(groundAngle * Mathf.Deg2Rad) * groundSpeed;
The problem is, for some odd reason when I move left, (groundSpeed is negative) velocity.y becomes something like 0.0000006, which screws up a ton of other code.
How do I fix this Unity math wierdness?
Here's what I'm trying to replicate: http://info.sonicretro.org/SPG:Slope_Physics#The_Three_Speed_Variables