Jump to content

OnTriggerEnter assistance, please


Recommended Posts

Okay, what should be a simple script is getting to me. I basically need to add lava damage to.. lava... However, upon entering the trigger, I receive no debugs at all. Which is odd. The box is quite large, so that can't be the issue. I thought it may be the UnRegisterForUpdate but I would still get debugs, yeah? Anyway, here it is. Point me towards my ignorance. I don't use trigger boxes much outside of teleportation, which has always worked fine, so I don't know what's going on here. Something stupid I overlooked I'm sure.

 

 

 

Scriptname BF_LavaTrigger_Script extends Actor  
{Needed for lava damage}

Int inTrigger = 0

Event OnTriggerEnter(ObjectReference Player)
	If (inTrigger == 0)
		If (Player == Game.GetPlayer())
			inTrigger += 1
			Debug.Notification("Entered lava. Taking health damage!")
			RegisterForUpdate(1.0)
		EndIf
	EndIf
	
EndEvent

Event OnUpdate()

	Float HealthP = Game.GetPlayer().GetActorValue("Health")
	Float HealthD = ((HealthP / 100) * 5)
	If (inTrigger > 0)
		Game.GetPlayer().DamageActorValue("Health", HealthD)
	EndIf
	
EndEvent

Event OnTriggerLeave(ObjectReference Player)

	If (inTrigger > 0)
		If Player == Game.GetPlayer()
			inTrigger -= 1
			UnregisterForUpdate()
		EndIf
	EndIf
	
EndEvent

 

 

Link to comment
Share on other sites

It isn't a guess. It is a fact. The script which should be attached to the trigger volume box needs to extend ObjectReference.

 

While technically, Actor does indeed extend ObjectReference and thus have access to OnTriggerEnter. Actors do not have the volume bounds to trigger the OnTriggerEnter event even if one were to devise a way for another actor to enter an actor running such a script.

Link to comment
Share on other sites

Oh my god. How could I not notice that. RIP. Such is the life of scripting for hours on end with minimal sleep.

 

Edit - Works just fine, I can be so dumb sometimes.

Edited by Rizalgar
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...