Legacy GM How to check if something is beneath a surface?

TheBroman90

Member
How can I make objects clickable only if they are not hidden beneath a surface?

Like in RTS games where you can't right click to attack enemies hidden under the black surface.
 
M

Multimagyar

Guest
I would rather instead check if there anything else is occupying the same position that the object that I could click is on. If I know it will always overlap then I don't even go into the details as checking if the depth of the obstacle is larger or smaller than the clickable's. By this I should be able to determine in an RTS situation that I can click an object or not I think. Unless your issue is a bit more complex.
 

jazzzar

Member
I would rather instead check if there anything else is occupying the same position that the object that I could click is on. If I know it will always overlap then I don't even go into the details as checking if the depth of the obstacle is larger or smaller than the clickable's. By this I should be able to determine in an RTS situation that I can click an object or not I think. Unless your issue is a bit more complex.
He didn't give enough info to know his exact case, that's what i'm waiting for, it's the reason i threw a vague reply :p
 

TheBroman90

Member
I'm not really making an RTS, but I thought the fog of war was a good example. My game is more like this:



If I hover over an object with the mouse I wan't to highlight it with an outline and some text. But only if the object is in the light and not under the black surface.
 
M

Multimagyar

Guest
He didn't give enough info to know his exact case, that's what i'm waiting for, it's the reason i threw a vague reply :p
Unfortunately vague questions happen way to often I just gave him and answer based on the information he gave us. ^^;

We shall wait and see.

Edit.: ninja'd

Edit2.: Well you could technically just say you have this specific circle you can hover in as well as you could cast a collision line between the character and the mouse so if the line hits the wall it will be in shadow so it will not highlight it. Should work for the player but if there is more than one light source and you want to do the same for the others it might be a few iteration between the light sources with the same method which can be less if you only activate the source when it's on the screen appearing.
 
Last edited by a moderator:

TheBroman90

Member
Well you could technically just say you have this specific circle you can hover in as well as you could cast a collision line between the character and the mouse
Yeah, that might be a simpler solution. I read somewhere that collision line was very costly performance-wise. Do you think that would be a problem?
 
M

Multimagyar

Guest
Yeah, that might be a simpler solution. I read somewhere that collision line was very costly performance-wise. Do you think that would be a problem?
In this case not really you don't need to re-check each time and the space it occupies may not be as large to matter too much. Sometimes however "costly" can be a harsh word. If you optimize it right as I said so you only cast from active lights that is on the screen, it should not be an issue.
 
Top