I’m trying to create a code where whenever the player mounts an animal, the player’s character becomes invisible, and whenever they dismount from the animal, the character becomes visible again. This is my attempt:
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Verse }
# A Verse-authored creative device that can be placed in a level
WolfDevice := class(creative_device):
@editable
WildLifeSpawn: wildlife_spawner_device = wildlife_spawner_device{}
OnBegin<override>()<suspends>:void=
WildLifeSpawn.RiddenEvent.Subscribe(OnMounted)
WildLifeSpawn.DismountedEvent.Subscribe(OnDismounted)
OnMounted(EventResult:device_ai_interaction_result):void=
if(Character := EventResult.Agent.GetFortCharacter[]):
Character.Hide()
OnDismounted(EventResult:device_ai_interaction_result):void=
if(Character := EventResult.Agent.GetFortCharacter[]):
Character.Show()
# Call it to enable invisibility
ShowPlayer(Agents:agent):void=
if(FC := Agents.GetFortCharacter[]):
FC.Show()
# Call it to disable invisibility
HidePlayer(Agents:agent)<suspends>:void=
if(FC := Agents.GetFortCharacter[]):
FC.Hide()
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces}
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Verse }
# A Verse-authored creative device that can be placed in a level
WolfDevice := class(creative_device):
@editable
WildLifeSpawn: wildlife_spawner_device = wildlife_spawner_device{}
OnBegin<override>()<suspends>:void=
WildLifeSpawn.RiddenEvent.Subscribe(OnMounted)
WildLifeSpawn.DismountedEvent.Subscribe(OnDismounted)
OnMounted(EventResult:device_ai_interaction_result):void=
if(ThisSource:=EventResult.Source?):
HidePlayer(ThisSource)
#Source is the agent; target is the AI.
OnDismounted(EventResult:device_ai_interaction_result):void=
if(ThisSource1:=EventResult.Source?):
ShowPlayer(ThisSource1)
# Call it to enable invisibility
ShowPlayer(Agents:agent):void=
if(FC := Agents.GetFortCharacter[]):
FC.Show()
# Call it to disable invisibility
HidePlayer(Agents:agent):void=
if(FC := Agents.GetFortCharacter[]):
FC.Hide()
Does this give you any ideas? The device_ai_interaction_result is a struct, so you can get to the agent by the Source, and using the query operator to access it. I am not able to test this at the moment.
Sorry for the delay in responding.
Actually, at the time I solved the problem in another way: every time a player mounts an animal, he receives an item and this item makes him invisible when it is in his inventory.