I’m working on a tutorial (substituting C# for JS) for a camera that zooms out when the player jumps. Changing the variable to restrict the maximum zoom out had no effect, so I tested some stuff in the main camera’s script and found an issue in this piece of code in the Update function:
if (camZoom)
{
targetCurPos = player.transform.position.y; // get target's current Y position
playerJumpHeight = targetCurPos - playerScript.groundPos; // get latest jump height
print ("STARTING POS " + playerScript.groundPos);
print ("CURRENT POS " + targetCurPos);
print (playerJumpHeight);
When I stand still, the starting and current positions both alternate between 0.74 and 0.7399999 and when subtracted, the answer alternates between - or + 5.0960464E-08. I have no idea where these answers are coming from. Am I missing something?
It's not "completely wrong", it's only very slightly wrong, and you should always expect that when using floating point.
– Eric5h5Sorry, but without KroniK's helpful answer I wouldn't have known that an E means that a number like 5.09etc. is actually a tiny decimal.
– CloverKitsuneE is scientific notation, essentially. So, 5.0960464E-08 is the same as 5.0960464 x 10^-8 . So that means you move the decimal eight places to the left. The same would be true if it was a positive eight, you'd just move it to the right eight places. Glad to help :)
– xKroniK13xThat's just scientific notation.
– Eric5h5