playMaker

Author Topic: Addforce in the direction of player?  (Read 1278 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Addforce in the direction of player?
« on: February 28, 2019, 02:21:47 AM »
Hi all,

I would love to implement knock back in my game where the player hit the foe and knock them in the direction of the player.I manage to push the foe away using addforce but stuck on how to get the move in the direction of player.

I look into "get forward direction" in ecosystem and transform direction in the PM action but clueless on to use it.

Can somebody help me.Thanks

devotid

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Addforce in the direction of player?
« Reply #1 on: March 01, 2019, 08:16:35 PM »
I would get the contact between you and the enemy and store the gameobject you hit and then add a empty game object to that enemy gameobject. The spawned empty game object will look at you "the player" in the first state with a look at action to "line it up" and then add a small force in that objects z+ local space direction (as you are already pointed in the right direction) and whamo. them bots are hitting back.

Kevin

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: Addforce in the direction of player?
« Reply #2 on: March 01, 2019, 10:24:44 PM »
Thats it...make sense really well.I try that and report.

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: Addforce in the direction of player?
« Reply #3 on: March 03, 2019, 02:27:27 AM »
trying to implement this but fail still there is knockback altho in wrong direction.

1.Upon hit a spawn an object
2.Make the object face the player
3.Apply force

Ok at 3.Apply force, i do have the vector of the spawned object, do i put this as At Position Or At Vector slot under the addforce action?

Thanks