playMaker

Author Topic: Correct way for knock back effect?? (3D platformer)  (Read 1511 times)

Qbanyto

  • Full Member
  • ***
  • Posts: 137
  • Vista Larga, Paso corto
Correct way for knock back effect?? (3D platformer)
« 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

Qbanyto

  • Full Member
  • ***
  • Posts: 137
  • Vista Larga, Paso corto
Re: Correct way for knock back effect?? (3D platformer)
« Reply #1 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?

Qbanyto

  • Full Member
  • ***
  • Posts: 137
  • Vista Larga, Paso corto
Re: Correct way for knock back effect?? (3D platformer)
« Reply #2 on: November 30, 2020, 09:34:57 PM »
Bump? (irronically)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Correct way for knock back effect?? (3D platformer)
« Reply #3 on: December 01, 2020, 06:05:03 AM »

Qbanyto

  • Full Member
  • ***
  • Posts: 137
  • Vista Larga, Paso corto
Re: Correct way for knock back effect?? (3D platformer)
« Reply #4 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?

Qbanyto

  • Full Member
  • ***
  • Posts: 137
  • Vista Larga, Paso corto
Re: Correct way for knock back effect?? (3D platformer)
« Reply #5 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