# How to reduce stamina when player enters a box?

**URL:** <https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053>\
**Category:** Blueprint\
**Tags:** overlap-events, unreal-engine, editor, UE4, Blueprint, question\
**Created:** [September 22, 2015, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053 "2015-09-22T16:10:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ENRELL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ENRELL](https://forums.unrealengine.com/u/ENRELL)\
**Post date:** [September 22, 2015, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053/1 "2015-09-22T16:10:07Z")

</div>

Hi folks

I am planning to have something like a poison gas surrounding a mesh. So i created a box and have it as a child of the mesh.

I then setup the onbeginoverlap and the necessary nodes but it does not work. Already have the overlap settings in the box and mesh to true. It is the same graph i used on an object but when i tried the graph on an object, the overlap works.

So anyone can help me or maybe give me an example of a simple graph where the player enter the box with gas, has his stamina reduced the longer he stays there.

Thank you

---

<div class="post-metadata">

**Author:** ![Est\_engine](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/est_engine/32/1008648_2.png) [@Est\_engine](https://forums.unrealengine.com/u/Est_engine)\
**Post date:** [September 22, 2015, 5:21pm UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053/2 "2015-09-22T17:21:06Z")

</div>

Hi man , on begin overlap , its an event that occur just one time, when you enter the trigger.  
once you are in there the event does not fire enymore, unitl you exit, then he cast, on end overlap.

There are several ways to to this , that all occur to different problem , here a working example,  
you can set a variable to the char/enemy/player who enter in the trigger, using the cast to method.  
So in the Char/enemy/player you can check at every thick , if you are in the damage area.  
if yes , you just detract the right damage of life, or stamina in your case.

Its pretty simple,  
you can also create a custom event, like, FIREevent or FOG event.  
that check your variable , and then reduce your life , your breath or your stamina.

 ![59713-damage.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/5/025595394573d5d48db6502d5392d17d070292a0.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_359f4d3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_359f4d3c](https://forums.unrealengine.com/u/anonymous_user_359f4d3c)\
**Post date:** [September 22, 2015, 6:12pm UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053/3 "2015-09-22T18:12:26Z")

</div>

Basically, add a Collision Component to your gas cloud object. Also add a variable to keep track of which character is currently inside the cloud. When the player enters the cloud, set the variable to the player. When he leaves, reset it to None.

 ![59730-gascloudoverlap_singletarget.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/b/7/0b75b1cea98c1a8a094de064fc88444b541077dd.png)

In the event tick, if there’s currently a valid target in the cloud, reduce their stamina.

 ![59732-gascloudreducestamina_singletarget.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/4/22498984671151e32f0b9f40ddf2d3beafa0e1f8.png)

Should it ever be possible for more than one target to be affected by the cloud, you could also keep track of a list of targets.

 ![59733-gascloudoverlap_multitargets.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/5/4/c54d60a09f95eaafbc1ec7b91ad54c08d80a71de.png)

 ![59734-gascloudreducestamina_multitargets.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/6/8/76800095034b6aae99b37dd024df80f9f01027f2.png)

---

<div class="post-metadata">

**Author:** ![ENRELL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ENRELL](https://forums.unrealengine.com/u/ENRELL)\
**Post date:** [September 24, 2015, 8:15am UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053/4 "2015-09-24T08:15:07Z")

</div>

Thank you for the kind reply.

I have gotten it to work on a player one time if he stays in the cloud, but not continously in the gas.

Seems like i cant use Cast To PlayerController node as i had a string trigged when casting failed.

Can you suggest other nodes to use ?

---

<div class="post-metadata">

**Author:** ![ENRELL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ENRELL](https://forums.unrealengine.com/u/ENRELL)\
**Post date:** [September 24, 2015, 8:16am UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053/5 "2015-09-24T08:16:22Z")

</div>

Thank you so much for the prompt reply.

Let me give it a try.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_359f4d3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_359f4d3c](https://forums.unrealengine.com/u/anonymous_user_359f4d3c)\
**Post date:** [September 24, 2015, 10:13am UTC](https://forums.unrealengine.com/t/how-to-reduce-stamina-when-player-enters-a-box/333053/6 "2015-09-24T10:13:15Z")

</div>

What _Cast to PlayerController_ node? I didn’t use the controller in my solution. You need to cast to your _character Blueprint_ because only actors of that time will have stamina that can be reduced.
