How can I detect overlap event?

I want to create a new device in UEFN. For example, a sensor that turns on the lights when entering a specific area. I would like this device to have direct event binding with existing devices, so that it can send and receive events when the sensor turns on or off. How can I detect overlap with collision in verse code, and how can I generate events?

Additionally, I’m curious if there is a way to check the verse source code of existing devices that have been created. Is there a method to review the source code?

Can’t you use a mutator zone that triggers when the player enters/leaves an area and use that event to send out triggers to other devices?
Or do you specifically want to use collision of objects and program your own events?

I think I can make this one, by combine other devices.
but, I want very simply.
so, I want show defult divices source code, and follow them.

Here’s what the code would look like, assuming you also want the lights to turn off after leaving the area. In Verse, for collision zones to detect overlapping players, you need to use mutator devices. Once players enter/exit the zone, you can just add the code of other devices inside the enter/exit function, or you can trigger a sensor (which you mentioned) like I show below, which can trigger other existing devices. Of course after adding this code, you’d need to “build verse code” so that the editor updates. Once updated, you add these devices into the map and assign them into the editor fields - which is only possible now that you have “editable” before each device. Hope this makes sense!

editable Zone : mutator_zone_device : mutator_zone_device {}
editable SensorOn: trigger_device = trigger_device {}
editable SensorOff: trigger_device = trigger_device {}
editable Light : customizable_light_device = customizable_light_device {}

OnBegin() : void =
Zone.AgentEntersEvent.Subscribe(OnAgentEnters)
Zone.AgentExitsEvent.Subscribe(OnAgentExits)
SensorOn.TriggeredEvent.Subscribe(OnSensorOn)
SensorOff.TriggeredEvent.Subscribe(OnSensorOff)

OnAgentEnters(Agent : agent) : void =
SensorOn.Trigger(Agent)

OnAgentExits(Agent : agent) : void =
SensorOff.Trigger(Agent)

OnSensorOn(Agent : agent) : void =
Light.TurnOn( )
#Add custom code to implement functions from other existing devices

OnSensorOff(Agent : agent) : void =
Light.TurnOff( )
#Add custom code to implement functions from other existing devices

2 Likes

@EV_WAKA , You should add this code to the snippets page, it’s a really good example of working with mutator zones in verse :wink:

Thanks for you code!!
very very usefull!!
Is there any other way to use only the overlap event of child collisions in the current device without using another device?

Thank you! Maybe I will.

1 Like