playMaker

Author Topic: Unintentionally killing the enemy in one shot.  (Read 1810 times)

mikejkelley

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Unintentionally killing the enemy in one shot.
« on: January 12, 2014, 02:46:15 PM »
Character is firing a semi-auto. I've made sure to set the raycast interval to 0 and to reset my raycasterWhatHit game obj var to an empty game object each time the mouse button is released.

The enemy's health manager is set up as in the attachment. Health is 100, damage is 34. In game, health becomes -2 with one shot, indicating that the event is running until it satisfies the less than condition.

Why isn't it running once then exiting?

mikejkelley

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: Unintentionally killing the enemy in one shot.
« Reply #1 on: January 17, 2014, 04:44:31 PM »
I feel like I've tried everything...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Unintentionally killing the enemy in one shot.
« Reply #2 on: January 17, 2014, 04:48:59 PM »
It is running once and exiting, then probably running several more times.

Whats triggering it? If it returns to the CheckIfHit state and the conditions for being hit are still met then its going to do it again, this can happen and usually be avoided by adding a Next Frame Event somewhere in the pipeline.

mikejkelley

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: Unintentionally killing the enemy in one shot.
« Reply #3 on: January 17, 2014, 08:46:13 PM »
I raycast from a gun and store the hit object in a global var. I make sure the raycast repeat interval is 0 (and have tried it w/ 1000 too). I have a next frame event that loops back to wait for input where I set the global game obj. var as an empty game obj. to make sure the enemy doesn't think it's being repeatedly hit. Still, they're dying before they're time. :(


mikejkelley

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: Unintentionally killing the enemy in one shot.
« Reply #4 on: January 17, 2014, 09:01:11 PM »
*their.

Ok, so I eliminated the greater than float compare and used a next frame event to exit out of the state. It works now, but why? Is float compare just that janky?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Unintentionally killing the enemy in one shot.
« Reply #5 on: January 17, 2014, 09:08:15 PM »
I would have to see the entire system to tell whats wrong with it.

But theres a number of things that could be happening, most likely its keeping a variable stored from the raycast (so it doesnt matter how often it casts) and using that to fire the hit event and reduce health and does it several times.

Just speculation though since I've seen that kind of thing happen on my own systems I figure it could be happening here. If you examine how each variable associated with the whole loop is working then you'll probably find some little kinks.

mikejkelley

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: Unintentionally killing the enemy in one shot.
« Reply #6 on: January 18, 2014, 01:52:45 AM »
Thanks for helping me troubleshoot this. I still don't understand why this was happening. The subtract health action was not set to "every frame (in the img it is but when tested it wasn't)" and there was nothing that would have made execution re-enter the subtract health event multiple times. Oh well.