I want to deal 1 damage to the player if they move on the z-axis in any way, but don’t know how to check to see if they have moved. Please be as descriptive as possible this is my first time using Unreal
@lordlolek This works well and I like the approach, the only issue with this is the damage will be applied on every tick.
@L0rdT4teX Can you tell us what it is exactly you want to happen? You mentioned you want to apply 1 damage when they move on the z axis. Do you need this damage to be applied once only when they move on the Z Axis (Jumping/Falling) or do you need to apply 1 damage over an amount of time they are moving on that Z Axis? (I.E. Apply damage each second they are falling/jumping)
I have realized that my character is also jumping on the Z-axis, so that might be why I am having so much trouble. Regardless, there is a point where my 2d character can get stuck between a moving platform and a wall and it clips behind the tile map I have set up, I want to kill the player if they do this but I don’t know how.
I have tried setting up a box that deals damage behind the tile map but that doesnt seem to work, and I want to set it up so if they clip through the level (go any direction on the y axis) it will deal damage.
I don’t have much experience with 2D, but I would think adding a collision box to the wall and when the player collides with the box, call the onBeginOverlap event and kill the character
!= 0 may be too precise for floats (or too sensitive), instead he should use NearlyEqual, with tolerance of something like 0.01 or so. But other than this yes that code is simple and good solution.
EDIT:
To not apply damage on every tick, do “slow tick”
- create float variable “slow tick period”
- create another float “last slow tick”
- on event tick compare if current game time seconds >= “last slow tick” + “slow tick period”
- if its greater then update “last slow tick” with current game seconds
- do your health update event.
I usually make such slow tick in blueprint like game mode game instance etc. and make it trigger dispatcher. This way i have event tick that i can regulate how often it happens. If you add integer counter to it, and tick happens for eg. every 1/4th second, you can make some stuff trigger only if int modulo 4 is == 0 (ie. every 4 ticks so every second) etc.

