playMaker

Author Topic: Need help with gun damage  (Read 2600 times)

Lostcity

  • Playmaker Newbie
  • *
  • Posts: 31
Need help with gun damage
« on: May 08, 2014, 08:44:59 PM »
I'm new here so sorry if this is an easy fix. I'm working on a simple FPS for mobile and I need some help getting the my gun model to do damage. I was originally using the FPS Constructor off of the asset store but I ran into a few problems that prevented me from moving forward so I'm having to kinda start from scratch as far as weapons go.

I currently have my gun model attached to my FPS controller. There are 2 cameras, 1 that renders only my gun and a main camera that renders everything else (so my gun doesn't go through walls). I set up my gun model to send a raycast on Mouse button down. The raycast comes from my main camera (which is a child of the weapon camera). Here is how my FSM is set up so far:

State 1: Get Mouse Button Down (send event "clicked")

State 2: Send Raycast from main camera
- Play Sound (weapon sound)
- Wait (.2 seconds before firing another ray)
- Get Mouse Button (Store result "trigger status" Bool): allows for repeated shots while holding fire button)

State 3: Bool Test ("trigger status")
- Send Event

I currently have one enemy model in the scene that is inactive (just for testing).  My enemy is set up with a Health float, Float compare and a death State if the health goes below 0.

I am confused where to go from here. I just need help getting my enemy to react to the raycast hit and subtract health until the death state (triggers destroy self). I'm a little lost on how to set up the variables to make everything work correctly.

Another issue is that while testing I will sometimes get a message saying that I have exceeded the loop limit. Unfortunately, I can't find how to make my loop limit infinite.

Again, I am new to PlayMaker (and pretty new to Unity) so any help is greatly appreciated. I wish I could go back to FPS Constructor but it gave me a performance hit and the heavy use of static variables gave me problems when trying to reset the scene.
« Last Edit: May 12, 2014, 04:02:12 PM by Lostcity »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need help with raycast gun
« Reply #1 on: May 09, 2014, 03:01:10 AM »
Hi

 Typically, the fsm that detect this trigger should send an event to the target that was hit by this raycast ( your ennemy), and that's how your ennemy is going to know it's been hit.

 Does that make sense?

bye,

 Jean

Lostcity

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Need help with raycast gun
« Reply #2 on: May 10, 2014, 07:32:47 PM »
Hi

 Typically, the fsm that detect this trigger should send an event to the target that was hit by this raycast ( your ennemy), and that's how your ennemy is going to know it's been hit.

 Does that make sense?

bye,

 Jean

Makes sense, I'm just a little lost on how to set up the variables. I decided to change my gun to shoot an actual bullet object instead of ray-casting the hit (makes the game look cooler and run a little smoother) but I'm still confused on how to make my enemy recognize the hit.

I currently have 4 enemy types in my game and each of them will have an "enemy" tag and layer. All of the enemy's will be in their own prefab and spawn at random locations.

Again I'm a Playmaker newbie (but its surely easier than regular scripting) so I'm not quite sure how to set this up in Playmaker:

-Bullet FSM-

State 1:(currently have) Add force to shoot the bullet. (though there may be an issue with this because sometimes my player movement will be effected by the bullet launch).

-(currently have) Collision Event

State 2: (need) Bullet to detect if it has collided with an object that has an "enemy" tag.

State 3: (need) If the bullet has hit an enemy it should then send some event and the enemy will loose HP.

State 4(or 3): (currently have) bullet explodes and "destroys self".

My enemy (so far) is set up like this:

-Enemy FSM-

State 1: Float compare (using "health" variable)

State 2: Float subtract (subtracts health then loops back to State 1)

State 3: Upon death (float compare sees equal or less than 0) Create game object (explosion)

State 4: Destroy self

I've been playing around with both the enemy FSM and bullet FSM and I can't seem to get them to send a message. I'd greatly appreciate it if someone could tell me what actions to use and how to set up the variables / events.

At this point I'm not sure if the problem is my enemy or the bullet. I'd also like to know how to set up how much damage my bullet does.
« Last Edit: May 10, 2014, 07:39:05 PM by Lostcity »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need help with gun damage
« Reply #3 on: July 16, 2014, 07:47:51 AM »
Hi,

 have you been able to make progress on this? Going through my backlog atm.


bye,

 Jean