Warmth Script and Widget v2.0

Requirements: Health package and setup on player

This is a basic script and widget. It was designed as a stepping stone. The goal was to explore a mechanic of a second type health bar which could affect health and function as a separate resource. This could be expanded to armor, shields, breath, etc. or just a modified version of this script.

How to use:
Add the Player Warmth Script to the player as shown here. It will damage health after there is no more warmth.


Highly suggest these setting be modified before use:

  • if you want to adjust the heat settings, check the heat box.
  • if you want to adjust the freeze setting, check the freeze box.
  • chillStart is disabled by default - enable it to have the player freeze on spawn.

The Campfire template:
To warm the player, a heat source is needed. This contains a trigger box on the campfire with these settings: (use as a reference if needed for customization)

  • add Script warmthTriggerScript
  • Check playersOnly
  • Set On enter to <entity>/warmthTriggerScript/OnEnter
  • Set On exit to <entity>/warmthTriggerScript/OnExit


changelog:
2020-12-17 - added campfire template
2020-01-13 - added warmthTriggerScript for Campfire
2020-02-12 - line 115 had an error, changed to heatTask
2021-02-12 - changed the campfire to Warmth Trigger
2021-03-02 - added radius, timetolive, rechargetimer, destroy, and effects toggle

2 Likes

Hey. I was just checking this out and spotted an issue with the implementation. The way the campfire trigger is currently set up means that it’ll effect all players not just the player that entered the trigger area.

What you’ll need to do is have a script on that trigger that does the following…

function ScriptName:OnTriggerEnter(player)
    player:SendToScripts("Heat")
end

Then you’ll need the same for freezing but with OnTriggerExit

Hope that helps!

1 Like

Thanks RussD. I like easy fixes.

added:

  • radius effect vice warmth in a box - set distance for effect to trigger
  • time to live - destroys parent of triggerbox at the end of timer
  • recharge timer - vice destroying box, it will have a cool down
  • effects can be added to turn off when the recharge timer is active.

howto use:

  • place object in world to be used as a heat source
  • advanced mode:
    • Create Child >> Trigger >> WarmthTrigger
  • basic mode:
    • add template “WarmthTrigger” to object

to configue:

  • onTriggerEnter needs StartRadiusSchedule
  • fill in other fields for radius.
  • time to live, destroy, recharge, and effects are optional
  • onTriggerExit is not used as there is a cleanup function