I found the "Basic 3D Project" TEMPLATE have updated!

Great! it looks better then before :grinning_face: :+1:

3 Likes

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!

3 Likes

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 :sweat_smile:

4 Likes

This is our focus, especially @jhonny.goransson is working hard on it, so perhaps can share more :wink:

3 Likes

Yes it’ll be added soon, within a month I think.

8 Likes

Great, can’t wait for it!

4 Likes

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.

1 Like

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

3 Likes

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 :sweat_smile: