I’ve been looking everywhere for a solution to doing a simple momentum based damage blueprint. Like say a boulder is rolling down the hill. I can make that cause damage for sure but it results in it always causing damage even if it isn’t moving and is touched. How could I make it do damage when it is ONLY moving down the hill???
start with GetComponentVelocity, you can test against its Length to see how ‘fast’ its going, so if its below a threshold dont apply damage. then on damage you can use a dotproduct to see if the velocity is towards the target. so if you’re behind ‘pushing’ you dont take damage either
Hey @RhyzzG!
You can use the Normal Impulse
pin of the Event Hit node and use the Vector Length
node to get its magnitude! The value will be very high, but you can divide it however you like to align with your damage system.
When it comes to @Auran131’s suggestion, he’s giving the right idea but I wanna point out that dot product wouldn’t be used here if there’s a possibility of the player character reaching the boulder from the sides or the back. Because we won’t be able to tell if the vector between the player character and the boulder aligns with the boulder’s trajectory from the front or the back using dot product. Additionally, the boulder’s velocity will change quite significantly on collision so you’ll also need to save the velocity instead of using the current one to determine the angle correctly.
But taking these aspects I went over into account, you can of course handle the logic yourself too!
Normal Impulse is exactly what you’re looking for tho, so I’d recommend using that.
Hope this helps!
First off I appreciate the both of ya commenting although I am still at a loss it seems.
This is currently what I have set up to cause damage although what I am experiencing is that damage doesn’t take place until after I have touched it at least once. Then any touch/hit after that is registered although at that point there is no moment but a flat damage number will work. It’s almost like the momentum isn’t being registered fast enough or something.
Hey @RhyzzG!
Sorry for the late reply, there was just too much going on.
So, can it be because you’re not first checking if the hit actor is the player character or not using a Branch
node?