Great! it looks better then before
![]()
Thanks! We needed to update it, as it was using the builtin .dae files that are deprecated and that we want to remove. Btw, you can use the texture in it as you wish, hope it will be useful!
We also plan to add also some more complex 3D templates/samples in the future. I think for example a basic FPS template would be nice!
Great to hear 3D is getting more focus!
I am also planning on starting a 3D series for FPS with Defold but waiting for the updates like new light component and better PBR. Is there any chance that they will be added in 2-3 months? I want to have the tutorial on the lates version of major 3D improvements and don’t want it to become obsolete/outdated in a few months ![]()
This is our focus, especially @jhonny.goransson is working hard on it, so perhaps can share more ![]()
Yes it’ll be added soon, within a month I think.
Great, can’t wait for it!
I find simple examples like this very helpful. In playing about with it I ended up with a script error. It took me longer than it should of to realise why!
Quiz
Why does the following (just the first two lines are new, and game input bindings for up & down set correctly)
function on_input(self, action_id, action)
if action_id == hash("up") then self.light.y = 2
elseif action_id == hash("down") then self.light.y = 1 end
-- move directional light based on input
self.light.x = 3 * ((action.x - 480) / 480) -- line 25
self.light.z = -3 * ((action.y - 320) / 320)
-- update uniforms for models with new light position
go.set("#cube", "light", self.light)
go.set("/plane#quad", "light", self.light)
go.set("/spheres#right", "light", self.light)
go.set("/spheres#left", "light", self.light)
end
When up arrow is pressed, it results in the error:
ERROR:SCRIPT: main/main.script:25: attempt to perform arithmetic on field 'x' (a nil value)
Strange, how could setting the y value make x a nil value?
How quickly did you solve it?
Don’t post the answer.
action will have x and y value only for mouse movements and clicks I believe. If you press a key, it will not have position so trying to get the x or y value will return an error. What needs to be done is to wrap the parts you check for action.x or y with: if action.x and action.y then
Sorry, the template script is usually to be deleted, so I tried to make it as simple as is and in the previous version it also handled only mouse/touch input ![]()

