#Alright Just thinking how I will be able
1 messages · Page 1 of 1 (latest)
FadeArea is not a Tilemap
It might often exist alongside a Tilemap
but it is not a Tilemap
FadingSprite will look at a list of FadeAreas
wherever the colliders exist
since it sounds like you're going to be watching for the player entering and exiting these colliders
thats just why i was thinking of the tilemapcollider
Thanks for helping me though.. I know i am a bit frustrating.. to say the least
right, but that doesn't mean a FadeArea is a Tilemap or a TilemapCollider
Right understood
a FadeArea is a FadeArea; that's it
[SerializeField] private FadeArea how would I reference it?
you'd want a List<FadeArea>
oh ok
then drag every relevant FadeArea into that list
here's what I'd do to decide if it's fading time
add using System.Linq; up top
then just do fadeAreas.Any(area => area.playerIsHere);
lanaguage integrated query
assuming the list is named fadeAreas
and that the FadeArea class has a field named playerIsHere
This returns true if any element in the list returns true when passed to that little function
area => area.playerIsHere
all this does is get playerIsHere out of the area
it's the same as
bool IsThePlayerHere(FadeArea area) {
return area.playerIsHere;
}
So, if one or more areas says "the player is here", that whole thing returns true
and you know it's time to fade the sprite out
Thank you, I appreciate you taking the time out to help me. I enjoy learning this stuff.. I used to know more.. but it is so much to remember.. been out of college for a long time lol
no prob :p
but yeah, the big idea here is separation of responsibility
what do you mean?
you have one class whose job is to look for the player and note that down
and a second class whose job is to do something if one or more of its areas says a player is there
pretty much, yeah!
this is a bit more manual, since we're just checking a bool on the "sensor"
you could have the FadeSprites subscribe to events from FadeAreas
hopefully sometime I will somehow have a way I can repay the favor
