# First person controller

**URL:** <https://forum.defold.com/t/first-person-controller/70172>\
**Category:** The Defoldmine\
**Created:** [January 21, 2022, 11:17am UTC](https://forum.defold.com/t/first-person-controller/70172 "2022-01-21T11:17:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Lytkin](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ivan_lytkin/32/2654_2.png) [@Ivan\_Lytkin](https://forum.defold.com/u/Ivan_Lytkin)\
**Post date:** [January 21, 2022, 11:17am UTC](https://forum.defold.com/t/first-person-controller/70172/1 "2022-01-21T11:17:36Z")

</div>

Simple first-person camera with dynamic collider.  
[https://github.com/abadonna/defold-first-person](https://github.com/abadonna/defold-first-person)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 21, 2022, 11:40am UTC](https://forum.defold.com/t/first-person-controller/70172/2 "2022-01-21T11:40:30Z")

</div>

😻

---

<div class="post-metadata">

**Author:** ![jhonny.goransson](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/jhonny.goransson/32/3864_2.png) [@jhonny.goransson](https://forum.defold.com/u/jhonny.goransson)\
**Post date:** [January 21, 2022, 11:42am UTC](https://forum.defold.com/t/first-person-controller/70172/3 "2022-01-21T11:42:03Z")

</div>

Looks amazing!

---

<div class="post-metadata">

**Author:** ![anon95708182](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@anon95708182](https://forum.defold.com/u/anon95708182)\
**Post date:** [January 22, 2022, 6:38pm UTC](https://forum.defold.com/t/first-person-controller/70172/4 "2022-01-22T18:38:00Z")

</div>

Hello there,

just tried your project, this is really nice!  
There is just one thing, at least for me: the mouse is captured forever, no luck with Space and Esc. I have to force quit the window. I am on a Mac mini M1, Monterey 12.1.

---

<div class="post-metadata">

**Author:** ![anon95708182](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@anon95708182](https://forum.defold.com/u/anon95708182)\
**Post date:** [January 23, 2022, 12:56pm UTC](https://forum.defold.com/t/first-person-controller/70172/5 "2022-01-23T12:56:00Z")

</div>

Hi again,

I played a bit more with your project and got my mouse back:  
First, I added the Escape key to the input bindings, then in your controller.script file, I added these lines to the input function ( the html stuff would need to be added as well if needed):

```lua
	-- touch or click event: the mouse is locked, the cursor hidden
	if action_id == hash("touch") then
		pointer_lock_ext.glfw_mouse_lock()
	-- pressing escape: mouse is unlocked, cursor visible again
	elseif action_id == hash("esc") then
		pointer_lock_ext.glfw_mouse_unlock()
	end

```

Not sure if that is the intended way, but now the mouse can be unlocked again and the project window closed without force quitting it.

---

<div class="post-metadata">

**Author:** ![TheKing0x9](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/theking0x9/32/13588_2.png) [@TheKing0x9](https://forum.defold.com/u/TheKing0x9)\
**Post date:** [January 23, 2022, 5:51pm UTC](https://forum.defold.com/t/first-person-controller/70172/6 "2022-01-23T17:51:09Z")

</div>

Wonderful ❣

---

<div class="post-metadata">

**Author:** ![Alexander\_Bulatov](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_bulatov/32/27139_2.png) [@Alexander\_Bulatov](https://forum.defold.com/u/Alexander_Bulatov)\
**Post date:** [May 3, 2022, 10:54am UTC](https://forum.defold.com/t/first-person-controller/70172/7 "2022-05-03T10:54:20Z")

</div>

Thanks for sharing! I wondering how make smooth mouse movement

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [May 3, 2022, 8:18pm UTC](https://forum.defold.com/t/first-person-controller/70172/8 "2022-05-03T20:18:56Z")

</div>

This is amazing!! Well done
