FPS camera DefOS / dx/dy issues (SOLVED)


#1

I’m working on a First Person Shooter style camera setup, and am using action.dx and action.dy - only problem is that the cursor lock / set functions of DefOS interferes with the built in dx/dy so that the dx/dy movement gets (approximately) reversed after a mouse cursor moves and then is returned to where it is.

Then do we need to be able to get mouse x/y position in DefOS and calculate dx/dy ourselves or should I be going about this another way?


#2

For my wolfenstein clone, i lock cursor.Then in game get dx and dy, from ne. https://github.com/d954mas/save-shelter-defold/blob/master/lock/extension/src/LockMouse.cpp

On input

elseif(action_id==nil)then
    local move=lock_mouse.update_cursor()
    if(move)then
	action.screen_dx=move[1]
    end

#3

This kind of thing doesn’t seem to work on Windows. See for yourself if you have Win box to test on https://github.com/subsoap/fps or can you see something I did wrong?

I also tested getting action.screen_x and action.screen_y and creating dx/dy on a function called in on_update but that didn’t work either. I’ll soon add get cursor pos to DefOS and see if getting cursor pos on update makes a difference.

Edit: turns out I was doing something wrong in the script by setting the last frame’s x,y incorrectly when they should have been view width/2, view height/2


#4

Did you fix it? This seems pretty unreliable to use the built in dx/dy when you’re moving the cursor with DefOS. Having a defos.get_cursor_pos function should do the trick though. I used d945mas’s Native Extension for my own FPS project and it worked great (unless you moved the mouse fast enough to get it out of the window in one frame).


#5

I’ll be adding a get_cursor_pos and get_cursor_pos_view to DefOS soon. They will be useful for other reasons as well.

I made a version of get_cursor_pos_view for local DefOS and it had the same behavior. So I tested the version where I made dx,dy based screen_x screen_y and last screen position (which is where I had mistake originally).


#6

Did you ever publish your FPS project?


#7

Nice! (I just tried it, looks cool.)

No, I never shared my FPS thing anywhere. Here’s the project zip if you’re curious. It’s a bit old, buggy, and only a basic test prototype though. (oh, and windows only I believe) The vertex shader is my brother’s work.

Ross FPS.zip (542.1 KB)


#8

I’ll check yours out now! I’m working with my brother on gamedev with Defold too.

There’s a couple of things I want to do such as figure out how to use first person models like in games like Overwatch.

Spent some time with yours. Really cool! Defold has big potential for 3D games… hopefully later this year we can see some more progress toward that in the editor and engine.


#9

Updated mine with more polish https://github.com/subsoap/fps

Adding collisions next. Then jumping. Then shooting / 3d object picking.


#10

you guys do inspire me a lot :wink: FPS with Defold may require some dedication, I can guess…


#11

Hopefully 3D feature updates do happen later this year, then we’ll begin to see more 3D games published made with Defold. A lot is already possible, but there are still existing bugs and missing features which make some kinds of 3D games a pain to make.

I think too many 3D mobile games are made with Unity and Unreal where they are overkill. Once we can show more devs what Defold can do, I think there will be a decent migration…


#12

If you were to list your top three missing features, which would those be?


#13

For 3D gamedev

  1. Dynamic mesh creation / modification. I want to be able to generate meshes based on scripts, modify them, set their materials, define their texture uvs and so on. This could allow us to generate terrain on the fly for example.
  2. Mesh based physics collision generator. Or better 3D collision tools in general… the basic shapes we have access to are not useful enough for real 3D scenes. Defold is using bulletphysics for 3D physics and there must be some features it has that would be useful for this. I want to make a lot of 3D prototypes that don’t seem possible right now because I’m stuck with using boxes for surfaces.
  3. Better 3D viewport in the editor. My ideal one would be similar to Modo. The current viewport has nowhere near the quality of life tools needed for editing 3D scenes.

Those three alone are obviously a lot to ask for…

There’s more too like:
There doesn’t seem to be many of the optimizations other 3D engines have because Defold is so geared toward 2D production. Some of the features like particlefx sprites need to be able to face the camera, but there’s no way to do that they always face a single direction only.
There’s no standard shading/lighting model. Something standard as a baseline would be nice. There’s no way to set global shader variables. There’s no way to send array data to shaders.

Currently 3D collision objects are missing in the viewport.

0%20-%20First%20Person%20Shooter%20Example%20for%20Defold

There’s a bug with 3D collision objects where they do not always end up where they are placed in the editor. I’ve made an issue and included a sample project where it happens.

If I were you I would survey other developers who use 3D engines and ask them what features they would need that Defold lacks.