Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Saputo on November 19, 2013, 01:11:12 PM

Title: Need Prefab advice(Solved)
Post by: Saputo on November 19, 2013, 01:11:12 PM
Ok, Iv worked this out to down tot he wire,But I need to be able to get more information. ok, first off,

1 my prefab is a projectile when it's shot it gets the information of a target, and then deals damage to that target once hit. (But I have the Targets health a a Global Float, I had to do this, so you projectiles could hit at once, and it would register the damage right. But the problem is clearing that Float once it dies, it wont set to 0 or anything it will stay at a Negative, so any clone of that target will get 1 shot-ed...)

Problem YES!,

So I tried having the prefab send an event to the target and then the damage was dealt on the target itself, but this caused issues were if 2 or more projectiles hit at once it would only register 1 hit, so i had to set it up How it's set up in Step 1.

So now I'm trying to figure out How can I have the Prefab when shot get the target, then get the targets information, and then Subtract the Float amount from that Target itself. and leave the clones at what they started with, in turn would have there Health coded on tot he Game Object and not a Global.

If I made this too confusing I'm sorry, just any question and I will answer it.
Title: Re: Need Prefab advice
Post by: Lane on November 19, 2013, 02:01:05 PM
Using global variables for instantiated objects is a bad idea, especially for something as relative as Health.

I suggest this (http://hutonggames.com/playmakerforum/index.php?topic=4989.0).

Done. Anything collider with an FSM named Health and a float inside it named Health will get subtracted the float named myDamage

You can see exactly how this is done in the Oomph Kit (http://hutonggames.com/playmakerforum/index.php?topic=5343.0), there are several working weapons in there using this method and as far as I can tell you can pile up all the simultaneous hits you want.

{edit}
Maybe it's not clear, but the prefab/scene disconnect issue is solved by setting up an empty placeholder variable of the object that the projectile is going to hit and filling that variable when the collision event occurs so you can design a working system in a prefab and it fills the missing info at runtime when it can see clearly whats happening.
{/edit}
Title: Re: Need Prefab advice
Post by: Saputo on November 19, 2013, 02:23:23 PM
I just got it to work using your actions :) thank you, now I just need to get the project to Find the Target it hit's b.c right now it's finding w.e target on the scene it wants, so I need to get that part to work right.
Title: Re: Need Prefab advice(Solved)
Post by: Lane on November 19, 2013, 02:44:16 PM
Why do you need to find any target? That's what the collision does.
Title: Re: Need Prefab advice(Solved)
Post by: Saputo on November 19, 2013, 03:51:45 PM
I've tryed to use get collsion Event but it wont work, the only way I can get it to work with with Trigger Enter. so with that I need to get it to find the Target, your attacking.