Hi

I found a code example on github for a FPS scene in godot and I used that code and added a first model.
The FPS code is working but I noticed that when you move the mouse up and down (and other directions) the scene gets "deformed".
You can see this when going to the arcade model I added and move the mouse when you are standing close to the model. You can see the model is deformed then.
I never saw such strange deformed thing in a FPS game. Also when I make my models (in Blender) and I rotate using the mouse, the model is not deformed.

Maybe there is something wrong in the code for the mouse or something like that? Or is there a setting I need to do somewhere in the project?
I use latest godot 4 Beta. Just open the attached project

https://godotforums.org/assets/files/2023-02-06/1675722887-338733-project.zip

  • DaveTheCoder I don't know offhand what the code would be.

    Something like this:

    func _input(event: InputEvent) -> void:
    	if event.is_action_pressed("ui_cancel"):
    		get_tree().quit() # Quits the game
    	
    	if event.is_action_pressed("change_mouse_input"):
    		match Input.get_mouse_mode():
    			Input.MOUSE_MODE_CAPTURED:
    				Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
    			Input.MOUSE_MODE_VISIBLE:
    				Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
    	
    	if event.is_action_pressed("window_toggle_fullscreen"):
    		match get_window().mode:
    			Window.MODE_WINDOWED:
    				get_window().mode = Window.MODE_FULLSCREEN
    			Window.MODE_FULLSCREEN:
    				get_window().mode = Window.MODE_WINDOWED
    			Window.MODE_EXCLUSIVE_FULLSCREEN:
    				#This mode is implemented on Windows only.
    				#On other platforms, it is equivalent to MODE_FULLSCREEN.
    				get_window().mode = Window.MODE_WINDOWED

    This is currently not taking the 'borderless' setting in project settings/window into account. May or may not be relevant. Also better naming scheme for the action so it would be more in line with the built-in actions would have been "wm_toggle_fullscreen" but I figured it would be clearer for the example so I'll leave it as is above. Keys to use could be for an example F11, Enter & KP Enter

I opened that project in Godot 4.0-beta17 and get the same result. I assume you mean while the project is running?

I wonder if it's due to the camera properties. I could only find one camera, in the Head scene, and its Projection property is set to Perspective.

Yes, while it's running and you move close to the model and move the mouse. If you look at square or rectangle parts of the model, it's completely deformed/stretched when moving the mouse.

Anybody who knows what's causing this or did I find a bug in godot 4,which is still beta?
In either case, this is not normal behavior in a FPS game...

If I change the camera's Projection property to Orthogonal, the deformation doesn't occur.

Godot 3.5.2-rc2 works the same way, so I don't think it's a bug.

I have little experience with 3D in Godot, and don't know if that mouse pan/tilt behavior can be customized other than with the camera. There are people here with much more 3D experience who probably have more insight on this.

Can you tell me where exactly the projection setting is?
This is my very first godot project ever...

Double-click on Player/Head.tscn in the FileSystem dock (lower left) to open the Head scene in the Scene dock (upper left).
Select the Camera node in the Scene dock.
The Camera properties can be adjusted in the Inspector dock (right).

Keeping the Projection as Perspective, and adjusting the other properties (FOV, Near, Far) also limits the amount of deformation.

Those properties are documented here:
https://docs.godotengine.org/en/latest/classes/class_camera3d.html#properties

Welcome to Godot 😃

    The Head node's script (Head.gd) might also affect the camera's behavior.

    DaveTheCoder

    I just tried setting camera to orthogonal but ... it doesn't work here!
    If I do that, everything is messed up when walking around. So you can't even walk because you don't see the scene in a normal way.
    How exactly can you make it work? Did you change other settings too which you didn't tell?

    Changing the other values while keeping perspective , is not giving the result I need.
    There are still deformed things.

      Megalomaniak
      As a beginner, it's too difficult 🙁

      Can you open the project and see for yourself?
      I can't solve it with the help I got already 🙁

        blender-girl

        Changing the camera to orthogonal removed the deformation, but caused other problems as you said.

        I think the solution is to change the code in Head.gd. That's what changes the view when you move the mouse. But I lack the knowledge to tell you how to do that. TwistedTwigleg is an expert on this subject.

        blender-girl As a beginner, it's too difficult 🙁

        Can you open the project and see for yourself?

        I already did and I saw nothing abnormal, hence my previous question. If you just mean the perspective/lens distortion then a barrel distortion to counter it somewhat is likely the answer, the linked example is probably one of the simpler solutions but to implement something for this is probably best done, if not outright needs to be done on a engine source level. Trying to apply a shader implementing this on a viewport might be doable, but would likely have it's own artifacts and issues.

        Simpler 'solution' might be to simply lower the FOV. FOV of 50 might perhaps be a good start to experiment with.

        No existing FPS game is deforming models if you move the mouse, so why is godot doing this?

        Could you record a video(or at least a screenshot) capture of this deformation, since I see nothing but the perspective distortion which very much is a rather normal thing in games that feature or allow you to change the FOV value to something really high. Very few games that far as I know have bothered actually implementing distortion remedies.

        I have set the camera's keep aspect to keep width and POV to 50. Changing the POV solved the issue completely!

        Can somebody tell me what code and where (in what file) I need to add to have a keyboard key for switching between full screen and window mode?

        L_Main.gd looks like the logical place, since it's already handling other input actions.

        You could define a new input action, such as "switch_view", in Project >> Project Settings... >> Input Map.

        I don't know offhand what the code would be.