Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Qbanyto on November 25, 2020, 03:35:01 AM

Title: Correct way for knock back effect?? (3D platformer)
Post by: Qbanyto on November 25, 2020, 03:35:01 AM
How do i create a knockback effect on my main character ?
I currently have this logic:

[hit from enemy
      -apply force (velocity change)
       -amount: 150 in the Z vector 
      -space: self
]

and that works PERFECTLY... as long as I am FACING the enemy that is hitting me.
But if my back is facing the enemy, it doesn't look right. he moves TOWARDS the enemy, not AWAY. (because I am applying the force to self i guess)

What would be a good, universal way to apply force away from source of enemy hit?

I saw and tried two custom actions  in the ecosystem. one called "move away" and another called "knockback" but they only work good if i had ONE. where here i have several and I would have to detect who is hitting me and from where. and it just further complicates things.

Modify message
Title: Re: Correct way for knock back effect?? (3D platformer)
Post by: Qbanyto on November 27, 2020, 01:57:14 PM
hmm. So i tried "explosive force" and that doesn't really do anything in this case. any ideas on the original question?
Title: Re: Correct way for knock back effect?? (3D platformer)
Post by: Qbanyto on November 30, 2020, 09:34:57 PM
Bump? (irronically)
Title: Re: Correct way for knock back effect?? (3D platformer)
Post by: heavygunner on December 01, 2020, 06:05:03 AM
Are you looking for something like this ?
https://hutonggames.com/playmakerforum/index.php?topic=21913.msg96126#msg96126
Title: Re: Correct way for knock back effect?? (3D platformer)
Post by: Qbanyto on January 25, 2021, 09:33:35 PM
So i gave this a shot and he ONLY gets push to the Z axis. so it i get hit from the left,right,front or back, he ALWAYS gets force applied to the negative Z (south).

how can I have the force applied to the opposite of the hit point?

If i get hit from the left, have my character get pushed to the right.
hit from the front, have character get pushed back.

any ideas?
Title: Re: Correct way for knock back effect?? (3D platformer)
Post by: Qbanyto on January 27, 2021, 05:15:36 PM
Update:
I figured it out. had to incorporate an additional variable that track my main character's movement. so now its working nicely :)

But I need to figure out a way to universify this logic. i will try to apply it to the ENEMY instead, reverse some actions and apply the force to the player.

this way the enemy are causing the players reaction instead of vice versa so that i don't have to add an FSM for every single enemy. I can just apply the one Fsm to the enemy, and prefab as many enemies as i want. i'll report back :p