How can I hide and lock my cursor position?

#1

Hi everyone. I’m making a first person shooter to try and learn Armory 3D. I’m moving here from the Blender Game Engine. My first project will be a sequel to my first Blender Game Engine game called Undead Fields. I just have a problem with the cursor. It moves normally so I cannot turn my character much and I cannot figure out how to fix this. Can anyone help? I basically just need my cursor locked to the center and then hidden. (By the way I don’t know any Haxe yet or Krom so I’ll need some help if that’s all necessary.) Thank you! :slight_smile:

2 Likes

#2

If you are using nodes, then you can use this


Show mouse-> Visibility of mouse, checking it will show mouse, unchecking it will hide mouse.
Mouse Lock-> Locking mouse to game window area, checking it will lock mouse to window area, unchecking it will unlock mouse.

4 Likes

#3

thx mate very helpfull

0 Likes

#4

In haxe you can lock and unlock the crusor with:

iron.system.Input.getMouse().lock();
iron.system.Input.getMouse().unlock();

2 Likes

#5

if you use this, how do you quit the game if you can’t drag the game window aside to click ☐close?

0 Likes

#6

tab out of the game… OTL

also: firing the gun the first time seems to eat the mouse cursor too
so maybe scripting the gun to fire an invisible, silent ball on startup would work too?

0 Likes

#7

First thing I do when starting a project is create a node scene trait. Put in an ‘on keyboard’ node set to released and escape, and have that go into a ‘Shutdown’ node.

0 Likes