Noob 3d Question?

Godot Version

4.3

Question

Hello, I have been working through the Brackeys 3D overview, and one thing came up that was bugging me to get the FPS controller to work I had to click with the mouse to be able to get the character to turn, I was wondering what was wrong with the controller up to that point, it works properly after that but I really don’t like the idea of the user (me) having to click in the window so the mouse can get the focus and work correctly. Now, is there anyway of doing this programmatically so that the mouse is ready to go from the outset?

I used to also have the same problem with Unity sans menu. If you had a menu before the game started it was hunky-dory, same with Unreal, click on the menu, get the focus.

Any help is greatly appreciated.

This is a feature in the OS, where the OS won’t give your mouse over to an application that just opened immediately if it’s not in focus. You as a game developer, you can’t do anything about this, and this feature is a good quality of life feature, otherwise many users might be confused as to why their mouse suddenly disappeared.

What does your code look like? I’ve had success capturing the mouse mode on _ready

It’s just the stock standard code used in the Tutorial, I don’t know enough about 3D yet to start playing around with it “yet”.

Also never had to worry about capturing the mouse yet on Godot so flying completely blind here. If it’s not available all good, but, if it is I would like to have a go. Right now I am trying to install Jolt Physics on 4.3

PS: just tried the following code in the func _ready

	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED;
	get_window().grab_focus();

and didn’t work.

Maybe it’s OS specific problem or you changed the mouse mode in running codes or tweaks some changes in project settings?

And are you sure you have set the mouse mode to capture in _ready?

As sure as I can be, this is the code in the main scene:

func _ready() -> void:
	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED;
	get_window().grab_focus();
	print(get_window() );
	#end _ready func

And I copied it an put it in the controller scene as well (and commented out the other and vice-versa) to make sure the code wasn’t being performed twice. And it didn’t work.

If it doesn’t work that’s fine as long as I tried to bend the code/program to my will :smiling_imp: It could be due to something that Brackeys did in the code that stopping it from working, this is my first foray into 3D in Godot and definitely not my last.

1 Like