box2dlights - how would you detect if a body is being touched by light?

I don’t really need it for anything right now, but I’d imagine it could be useful for something.

It just occurred to me when I was playing around with it… would it be possible to detect if a body is being touched by the light from box2dlights?

I initially thought it might be easy by getting the distance of the rays of light and seeing if a Body X is within that amount of distance from the source of the light… but what if there’s another body in between Body X and the light source that is blocking the light source/preventing the rays from touching Body X?

I would guess that

RayHandler#pointAtLight()
RayHandler#pointAtShadow()

are for that task.

^ Ah, those functions didn’t immediately jump at me as made to be used for this purpose when I was skimming through the list of methods. Thanks.

I wonder how straightforward these would be to implement. I would guess that if a light source is hitting another body, the points being occupied by that body would return true for pointAtShadow even though its surrounding points would return true for pointAtLight. idk. Will explore this later.

Heya.
I pretend to use lights in my game, in the future.
Is there anything i should be aware of?
Like i need to use box2d physics or box2D??? ?
Also, all my tiles, walls, and my player needs to be extended or implements anything ?

Im using libgdx :smiley:

Not sure what you’re asking but the only other major I had with box2Dlights is discussed here:

box2dlights messing up the camera view

oh , its ok, its because that later i might need to use it.
So im just wondering if i should code in a certain way, to make it easier to adapt it later.
Like, do i need use actors?( just an example)

:smiley:
Or maybe i can use libgdx native methods?

You don’t really have to code in a particular way. box2dlights is quite simple to integrate into the code once you understand how it works.

I can’t say anything about actors since I don’t use them though, sorry.