I really need help with an issue I have with my game. To get a moving object, in this case a boulder (round sphere mesh). I am curious how I could (in blueprints) do the following:
When hit by object (discover which angle the hit happened)
Add Force/Launch in opposite direction
I have tried some possible solutions here on the answerhub but to no conclusion.
Thank you for your answer. I tried that, but my character just stands still like a brick.
I also tried increasing the mass of the object, but it didn’t make any difference.
The solution in link 3 should work, but you have to multiply the normalized vector not only by -1, but by the amount of force you want to apply. And I believe it’s better to Add Impulse instead of force, and don’t forget to connect the object you want to push to the Target input.
Thank you again, but still no effect. My character stands still like a wall, but the object itself gets pushed back upon collision with the character, but not by the effect from the blueprint I think.
The character is still not moving from its position when being pushed. But if I move the character towards the object then the blueprint works and I am being pushed back.
There also is added another bug after this. When the character is being pushed, then it bounces infinitely up and down.
This screenshot of yours, it’s in the character BP, right?
What if you use the Launch Character node instead of Add Impulse? And don’t use the capsule component there, I believe it will use Self automatically (or connect Self as a target if not).
The character goes on bouncing because you have to check if the Other in the Hit node is your boulder. Because like this all the hits will cause the character to be pushed, against walls and ground and everything else.
Next, if the character is launched when you move forward a bit, it means that the launch itself works, but the hit event doesn’t happen for some reason. My guess is the actual engine physics stops the boulder before it hits the character capsule component. Do you have any other components in your character that stand in the way and might block the boulder from reaching the capsule?
Or by something like timeline of linear interpolation? No
What if you just throw any other object at the character, does it work? (remove cheking for the boulder first). - No, same issue as with boulder (sphere).
P.S. What is the size of the boulder? Is it possible that it pushes the Character downwards? - Size is irrelevant, I tried with smaller size but the problem still persists.
Okay, as a last resort, try setting the boulder’s collision preset to Overlap Pawn. In the Character BP, set On Begin Overlap event for the Capsule, Find Look At Rotation from Other Actor’s location to Self location, Normalize the vector you get, multiply it by the amount you want, and feed it to the Launch Character node. If that works, you’ll know the problem is in the Hit event. If nothing changes… well, I hope something changes =)