playMaker

Author Topic: Send Event - Global Variables - Prefab Problems  (Read 1321 times)

san

  • Junior Playmaker
  • **
  • Posts: 93
Send Event - Global Variables - Prefab Problems
« on: September 27, 2020, 09:56:40 PM »
Hello, I am having a little problem with Send event. I know this is super simple thing but when is come to Prefab somehow....send event and global variable is breaking it.

So I setup a bullet with RayCast and telling it what is hitting on Object. Then Check tag if the bullet is hitting random object or Enemy or something else. Then they do "Send Event" on those Specific Game Object to do check on Enemy Health. Those Game object is has Get Owner Global Variables to track in Bullet Send Event.

For example, I have a bullet that hit Enemy. But I already Prefab both Bullet and Enemy. Also Enemy Has Get Owner Global Variable so I can Send event from Bullet to Enemy Health to subtract health. It does work ~! But If i have two or three Enemy Prefab sitting in the game with Same Get Owner Global Variables, the bullet is hitting only the first Enemy effecting on Enemy Health, Not second and third Prefab enemy Enemy Health.

So i wonder do i need to set up 5 or 10 different Enemy with different Variable to have combat system? Is there better way? I also try using BroadCast all and it effecting to all Enemy Prefab Health system. I dont know how to setup multiple prefrab.

Please Help thanks

san

  • Junior Playmaker
  • **
  • Posts: 93
Re: Send Event - Global Variables - Prefab Problems
« Reply #1 on: September 28, 2020, 12:07:16 AM »
I have try these send event. Only Two send event are working (Broadcast All and Game Object with Global Variable).
-Broadcast All event effecting all Enemy Health, that i dont want.
-Game Object with specific Get Owner Variable seem working on First Enemy Prefab Health system, but Not effect on Second and Third Prefab Enemy Health System.
-Game Object FSM seem doesn't work with Global Variable either. I dont understand this one. This Send Event type supposed to be sending exactly on specific game object with fsm and global send event, and this doesn't work too.

Any help ?
« Last Edit: September 28, 2020, 12:10:54 AM by san »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7619
    • jinxtergames
Re: Send Event - Global Variables - Prefab Problems
« Reply #2 on: September 28, 2020, 06:01:35 AM »
Hi.
To trigger, you are using a trigger event or collider event.

when one of those is triggered, you should store the object in a variable.
Then use that variable as gameobject.

if the enemy health is on a different object on the prefab you can do this :

On the enemy, you can place a fsm called (for example) 'Data' (must be on the object with the trigger/collider that will be detected).

Then on the 'Data' fsm you can create a game object variable called (for Example) 'Health manager'.

Then on you bullet pistol you can do first 'Get Fsm Game Object' and store the object.
Then do a send event to that object.

You also could send event to the data fsm and from there send event to the health fsm.

san

  • Junior Playmaker
  • **
  • Posts: 93
Re: Send Event - Global Variables - Prefab Problems
« Reply #3 on: September 28, 2020, 03:51:52 PM »
Yes I try with trigger enter event for bullet, its working now~! Thanks ~!
But why Send event doesn't work on Multiple prefab? i still don't understand this part.

-Bullet has tag bullet , Enemy has Trigger event that waiting for bullet tag to enter then do health damage. (its working)

- bullet has Raycast event , if tag compare see enemy tag collider then bullet send event to Enemy Health Game object with specific Global send event name then do health damage.

They both do similar but when multiple prefab in scene, send event doesn't effect on following prefabs game object. Is there something that i dont understand anyone wanna help me understand?


-Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7619
    • jinxtergames
Re: Send Event - Global Variables - Prefab Problems
« Reply #4 on: September 29, 2020, 08:32:38 AM »
Hi.
Scene Objects can not communicate with Project objects.

you are targeting a prefab directly in you project folder, not in scene.

The prefabs that are created there are clones and therefor are different objects.

maybe this video can help :