Godot 4.6.3
How do i use Clip Children and not move the child while moving the parent?
so ive been working on a game thats very dependant on a flashlight mechanic, and since my game is 2d and stylized, i want the flashlight to be basically a spotlight overlay (sprite2d) that clips the bright render (also a sprite2d) of the players environment. the outcome is the lit up environment displaying only in the range of the spotlight overlay. now i have succeeded in this; the problem is, when i move the spotlight overlay, the bright render also moves with it, which ruins the entire illusion of it! and i have already tried setting the child to Top Level, but that breaks things even more.
is there a solution to fix this?
Can you show with an image what exactly you mean?
sorry but it says new users cant put embedded media on the post. but if i were to describe it, basically i move the flashlight overlay (the parent) around but the problem is the bright render (office) moves with it.
alternatively, if you could just tell me how to mask the office without it being a child node that’d fix my problem.
couldn’t you just use a directional light 3d for that or am i understanding your issue wrong?
i think ur understanding wrong. what i want to happen is that the bright render gets displayed through a masked overlay of a spotlight; i cant use real-time light on the scene because its 2d.
alright. i updated the post
i think i still dont quite get what you mean
is your game a sidescroller, topdown or what kind of 2d game is it? For most of them you can still use lights
i know its not a great example but i used lights for a game i made for my Uni
It does have some issues but the trees throw shadows if you need that. i had to add an occlusion layer for them
Edit: The flashlight is just a gradient texture for a pointlight 2d
ok how do i say this… its a fnaf fangame.
the way it works is that basically everything you see in the game is a render of a 3d model or environment made in a modelling software (which i used blender for); so using a realtime light source on it would look out of place and cheap.
oh wow i can send images now!
how its supposed to be
what happens when i move the spotlight overlay (the child moves with it which makes this happen)
oh okay, i see now. so the flashlight overlay is a prerendered image overlaid over the game?
May i ask why you are doing it this way? Wouldn’t it kind of make sense to make a 3D game in godot with this perspective?
well yeah it would, however the 2d perspective shader that im using compared to the environment being 3d hits alot differently. its uh.. something thats impractical but kinda mandated now for these kind of projects.
ive already made the same type of games in realtime 3d, and id just rather doing it like this
so you only have defined points where you can use the spotlight right? as you need prerendered images?
Can you send an image of how your scene tree is structured and what exactly the spotlight overlay does?
alright so with your first question, i want to make my game more free rather than having 2 renders of the left and right side of the office being lit up; however scott cawthon himself did use the method you mentioned on his fourth fnaf game.
as you can see the spotlight has the bright render as its child so it can clip onto it
the spotlight overlay is basically a clip mask
i think you can still just make this using a light with the lighting layer for just the bright office with transparency. and i think it does make more sense with the spotlight as a child of bright_office. you might need to invert the mask if that makes sense
how could i invert the mask?
or wait, i guess you could use this on the bright_office:
and then just move the position of it around i guess?
then you wouldnt even need the node spotlight
well this is good, but it only works for sprite3d’s..
oh yeah that is an oversight on my part but i think it should be pretty easy to change to make it work on 2d