playMaker

Author Topic: Need Prefab advice(Solved)  (Read 2306 times)

Saputo

  • Full Member
  • ***
  • Posts: 107
Need Prefab advice(Solved)
« 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.
« Last Edit: November 19, 2013, 02:23:37 PM by Saputo »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Need Prefab advice
« Reply #1 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.
  • Projectile gets fired.
  • Projectile hits something.
  • Store the collider in a GameObject Variable (hitThisThing)
  • Use Subtract FSM Float on hitThisThing in FSM:Health to variable Health the value myDamage

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, 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}
« Last Edit: November 19, 2013, 02:23:50 PM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: Need Prefab advice
« Reply #2 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.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Need Prefab advice(Solved)
« Reply #3 on: November 19, 2013, 02:44:16 PM »
Why do you need to find any target? That's what the collision does.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: Need Prefab advice(Solved)
« Reply #4 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.