Getting all objects with the same material

Hello, I am currently making a platforming level where you have to progress vertically to collect blocks to place on pressure plates, throughout the level there are walls on each floor that make you go in a certain direction since there is also a grappling hook mechanic. There are four different vertical levels on the same map and I added some effects so that on the top of all the walls there is a lava material. My problem is that I want to make a reset function where if you land on the lava, you “die” and go back to the beginning of the level or at least it sends you to the last floor you touched. I was wondering if there is anyway to get all objects that have the same material or will I have to just go and add a tag/reference to each object and then go from there?

from what i understand, you want to tell your level to reset certain areas upon dead, right? for that you would have something like a checkpoint?

  • First i would tag the Checkpoint with an Id (numeric would be enough). ADDED: on overlap event, cast the OtherActor and asign
  • Set a EventDispatcher into PlayerCharacter or PlayerController (doesnt matter i think).
  • Set an variable (InCheckpoint for example) on each object identifying on which level they are (most likely, if the lastCheckpoint of the player is the same as our checkpointId, it means the player already passed us)
  • Bind the objects to be resetted to this Dispatcher (in my screenie, Torch)
  • Ingame: Set the CheckPointId into PlayerState as the LastCheckpointId
  • when you die, PlayerCharacter (or playerController) sends a Dispatchet call. every object that is binded will recieve the message and check their InCheckpoint with LastCheckpoint, if the last checkpoint is bigger (or lower, or w/e), executes a function to do whatever your logic demands to.
  • replay and die again.

But do you know if there is a way to get all objects with for example the lava material? Or should I just go and add a tag to the objects that are lava?

i doubt there is. and tagging them would mean that at some point, you are going to ForLoop every single actor and compare it, when you could just implement a dispatcher.

Awesome, thank you for clearing things up!