Godot Version
4.6.2
How do I make a lamp type light?
I’m trying to create a simple lamp. Nothing fancy. I tried the answer I found online: Add an omnilight3d to the player or camera.
That’s what I did. Just an omnilight in front of the player for now.
But the effect I’m getting is this:
Is the light position not updating along with the player?
I don’t get why the light is not continuously moving instead of appearing and disappearing. And it looks like once it’s on the screen, it stays static until after the players moves ahead.
Post a screenshot of your scene structure.
Allow me a question. Is the player capsule mesh active? Is the light inside on the limit of the player mesh? I think you should disable the mesh and leave only the collider.
The player capsule mesh was active but the light was well ahead of the player. I deactivated the mesh and put the light completely out of the player reach and the light behavior didn’t change.
1 Like
What happens when you only rotate the camera. What happens if you’re not in a narrow corridor?
This looks really weird. What I would do to debug this is make a script that prints the location of the player’s CharacterBody3D and the OmniLight3D so you can figure out where the strange movement is coming from.
If the light is just spontaneously moving around (which it shouldn’t be) you can force it to obey you by adding this script to the light:
func _process(delta: float) -> void:
position = get_parent().position + Vector3([insert where you actually want it to be here])
This comes with the caveat that if you want to move the light you need to go back into the code and manually update the position. But, it will behave exactly how you program it to behave.
Kryomaani, on Discord, solved the problem.
It looks like you might be using per-vertex lighting on the environment? If that’s the case, the effect is created by your vertexes being too big to catch the light, as the light values are calculated at the corners and then interpolated for the rest of the vertex.
if the light isn’t hitting any corners then the face won’t light up
He was right. I had “Force Vertex Shading“ on.
Once I deselected the option, the “lamp“ worked as intended.
Thanks to everyone answering!
2 Likes