CurryKitten / CurryKitten-Sim

FPV quad simulator
67 stars 7 forks source link

User found his environment upside down! #84

Closed CurryKitten closed 3 years ago

CurryKitten commented 3 years ago

A user reported his sim was showing everything as being upside down... which sounded odd so I asked him for a screenshot

image

What's weird about this shot is that we seem to have an external image of the quad, but not in the normal way. The in-game FPV camera is actually forward of where the camera appears to be (so as not to make the arms seem overly-elongated when the FOV is increased) so it seems to me that the camera is somehow at 180 degrees, and hence looking back it the quad and making everything upside down.

I was able to replicate this by manually rotating the camera, but I have a camera range of 0-70 degrees, so you shouldn't be able to turn it all the way over.

However, I went back through the code and found that part of the code that should be within the confines of the bounds check wasn't there.

if (Input.GetKeyDown(KeyCode.P) && !velConScript.tiltOnAxis)
{
    if (cameraAngle < maxCameraAngle)
    {
        transform.Rotate(-1, 0, 0);
    }
    cameraAngle++;
    if (myCamera.name == "Far Camera")
    {
        rateUI.FadeIn();
        cameraAngleUI.text = cameraAngle.ToString();
    }
}

With the cameraAngle++ outside of the bounds check, it means that you could continue to press the P key and although the camera wouldn't go able 70 degrees, it would think that the camera angle was much higher. The result of this means that you could increase the camera angle to 200 degrees, with the actual camera staying at 70, but if you put it back down to 0 then the actual camera angle would be at -130 degrees - and so you could end up looking the wrong way.

There's a very simple fix for this which is to put the cameraAngle++ within the confines of the if, and the user should be able to reset to default settings to pull things back to normal for now. Will keep this issue open until he confirms that.

if (Input.GetKeyDown(KeyCode.P) && !velConScript.tiltOnAxis)
{
    if (cameraAngle < maxCameraAngle)
    {
        transform.Rotate(-1, 0, 0);
        cameraAngle++;
    }
    if (myCamera.name == "Far Camera")
    {
        rateUI.FadeIn();
        cameraAngleUI.text = cameraAngle.ToString();
    }
}
CurryKitten commented 3 years ago

Got confirmation that the user has his sim up the right way after the reset.