playMaker

Author Topic: Enemy Shooting And Damage to Player  (Read 23092 times)

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Enemy Shooting And Damage to Player
« on: October 21, 2012, 08:15:18 PM »
Hello--- Are there any tutorials on setting up the enemy to shoot at and damage or kill the player?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Enemy Shooting And Damage to Player
« Reply #1 on: October 22, 2012, 03:29:10 AM »
Hi,

 maybe not tutorials as is as far as I know, but I have worked on a very powerful solution, called targetPro. it might be something you would be interested in. I have created a playmaker set of custom actions and proxies for you to work with this system right within playmaker.

https://hutonggames.fogbugz.com/default.asp?W993

This will give you already 99% of what you need to set up shoots, damage, ennemy detections and firing behaviors. It's very impressive.

Bye,

 Jean

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Enemy Shooting And Damage to Player
« Reply #2 on: October 22, 2012, 04:22:30 AM »

Hi,Jean

I saw TargetPro That's not what i need I am working on a fps with third person characters that will be shooting handguns , rifles and rocket launcher at the player.

thanks

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Enemy Shooting And Damage to Player
« Reply #3 on: October 22, 2012, 12:37:21 PM »
I sort of did that when starting with Playmaker. Some tips:

Store the player GameObject reference in a global var.

Health: Create a manager that handles that issue, only for player (therefore, player HP should be a global var). Each foe should manage it's own HP.

Shoot: I made 3 states for my foes: Idle, Following, Attacking. When in 'atk' state, they SmoothLookAt the player and instantiate a bullet object, applying velocity on Z axis. Obviously, the look at action will proceed as well while in 'follow' state.

Dealing damage: Have the bullet tell the manager how much damage it'll deal to the player. Detect collision between player and bullet, and send events as needed to deal the damage (that's why the player HP being global is useful). If player is intended to damage, and kill, foes, the same. I'd recommend having a bullet prefab that deals damage only to player, and one only to any foe. I had problems using a shared bullet.

Note that you, most surely, will need about 4 FSM on each character.

Hope that helps you.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Enemy Shooting And Damage to Player
« Reply #4 on: October 25, 2012, 04:35:58 AM »
DARK_ETERNAL Thanks but do you have a screen shot of your FSM  setup

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Enemy Shooting And Damage to Player
« Reply #5 on: October 25, 2012, 11:00:11 AM »
I'll make them for you. Since my foe and player FSM setup is similar, I'll only pass you my player's Setup. You should be able to adapt the foe's from it. Just give me a second.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Enemy Shooting And Damage to Player
« Reply #6 on: October 25, 2012, 11:16:39 AM »
Here you go. I added screenshots for my player setup, 4 FSM in total, managing position update (so foes know how near are from it), shooting and such things; the health manager that will reduce player health if hit, and a game manager that will response if player kills all foes or gets killed. Any questions, feel free to ask.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Enemy Shooting And Damage to Player
« Reply #7 on: October 25, 2012, 11:21:48 AM »
Nope. Foe's FSM is lightly different from Player's, so let me add screenshots for my setup. Again, feel free to ask anything you don't get from it, although I don't think those screenshots are self-explanatory by themselves, but you'll do better if you try to figure out the FSM flow from them.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Enemy Shooting And Damage to Player
« Reply #8 on: October 26, 2012, 04:47:28 PM »
Thanks.

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Enemy Shooting And Damage to Player
« Reply #9 on: October 27, 2012, 09:07:59 PM »
 Thanks DARK_ETERNAL  I am new to playmaker I see your flow charts but I cant figure ot the actuall set up.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Enemy Shooting And Damage to Player
« Reply #10 on: October 29, 2012, 01:51:06 AM »
Hi michaelwwswr

The turret example of targetpro might be misleading indeed for your case.  It's totally capable of doing any kind of shooting, be it your ennemies firing anything to your player. You simply define targets, firing entities, you also define what they fires and how it damages affect the target when hit, etc etc. I would strongly suggest you get in touch with targetPro guys and ask about your needs.

bye,

 Jean

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Enemy Shooting And Damage to Player
« Reply #11 on: October 29, 2012, 10:35:21 AM »
Thanks Jean

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Enemy Shooting And Damage to Player
« Reply #12 on: October 29, 2012, 11:25:25 AM »
Hello, michaelwwswr.

Basically, the foe FMS has this flow:
  • FSM: Manages attack states, starting from Idle, goes to Following, if player is near (you have to define how many distance there should be between player and foe to have the enemy follow the player, then, if foe catches it, goes to attack mode (I use a lesser distance than the follow one)
  • FSM 2: Will compare current FOE distance to player's (which is a global var), then send a CompareDistEv to FSM 3
  • FSM 3: Receives CompareDistEv from FSM 2, then sends events to FSM to set the action state for Foe.
  • FSM 4: Checks for Foe's HP, managing when is dead. Activates when it gets the ApplyDmgEv, from the bullet (the same for Player's FSM 4)

You might not be able to catch from it, because I didn't send the state actions. Take these references to set up your foe, have a player dummy and make, at least, the distance thing work. If you still don't get this, do come back and I'll prepare an export of my scene so you have complete access to the events, actions and such things. Be warned, this logic is based in sending events through FSMs, so, if you follow this approach, you WILL use pretty often the 'Send Event' action with Broadcast All or GameObject FSM targets.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

michaelwwswr

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Enemy Shooting And Damage to Player
« Reply #13 on: October 30, 2012, 06:48:44 AM »
Thanks,  DARK_ETERNAL Jean told me about target pro I checked it out , it's a good product. But I would like to use playmaker this is why I purchased playmaker to avoid buying more shooting assets. I can set up the Idle and all the Animations. I searched every where for shooting tutorials on the Foe set up there are none.  I got the distance and follow. I see your fsm set up, I do not know what variables, you used though.

are these events or variables -CompareDistEv, ApplyDmgEv,
« Last Edit: October 30, 2012, 07:09:57 AM by michaelwwswr »

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Enemy Shooting And Damage to Player
« Reply #14 on: October 30, 2012, 04:13:10 PM »
Events. I use a convention that, everything that is an event, should have an "Ev" suffix. Variable names don't really matter, as long as you understand where are needed. I use a follow distance and an attack distance variable to tell how NEAR should be the player from the foe to follow/attack it. Those vars are local to each foe instance, so you can create different patterns.

Maybe you would rather having me to prepare an export of my scene?
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8