[Solved] Spawner, How to distinguish the entities spawned?

I am trying to have characters spawn in on a spawner. It is all working so far, but if I hit one of them and do 50 damage to there 100 health, all of them that are spawned take 50 damage, because they are all using the same script canvas graph. Does anyone know how to give every child that spawns from a spawner its own health that gets damaged only if he gets damaged? I cannot seem to be able to figure this out for Script Canvas. This is the graph I am using to do damage to the Character. The Hit Test is a Script Event Sent over every time I hit a character.

1 Like

You must use Raycast(Hit Point)+Tag(your character/your enemies)+ number variable(health) , You do not use Script Event , cause script send/rec signal for all your character in one time (you trying use GunHit Event but it is not logical correct) :slightly_smiling_face: I hope useful my tips :blush:

I Solved for you , I publish a video tutorial for you … soon :wink:

@WashedUpStudios
PhysXRaycast & Global Variable Script Canvas Graph :point_down:
PhysXRayCastGlobalVariableAhmadKarami.zip (26.6 KB)

Part10_PhysXRayCast and Global Variable Tutorial_Kurdish Language_Lumberyard 1.25 :point_down:

1 Like

I watched this, and copied everything exactly, but still no luck. I made a cube and added everything that should be needed. Is there something else needed on the Player? Because my Cube looks just like your cubes with the tag Box, but the Raycast does not pick it up when I look at it. Plus I do not have the UI you have when you start draining the multiplier. Is that needed? With whats in this video I do not believe this can be replicated.

I inserted my graph in top :point_up_2:
I did this without ui-target-point, cause PhysXRaycast running in game, you can add ui-target-point but without ui-target point physx raycast does work :slightly_smiling_face: yes you need to 1000 meter(custom number by weapon range you want) by multiplier node for forward direction , also you must use point light(diffuse multiplier param in point light) for health box , yes , you must use point light component , you can turn off light(visible=false) but you must use point light component , cause this replace for global variable, that is all , very easy :wink:

Also you must use physX collider/physX rigid body or physX character component + tag component , you do not forget , you must the graph top add to your camera player entity , I hope you do it , you get good result like me :blush:

I used tag for all boxs , if tag = “Box” decrease health
else if tag!=“Box” like MyBox or any string value , no change health :slightly_smiling_face:

@WashedUpStudios

Are the entities you are spawning dynamic slices?

Tell me a bit about how this is all set up and I will try to help.

Raycasts are fantastic in certain situations, but not necessary depending on what you are doing.

Also, recommend you do not do things on tick unless you have to. For example, if your game has a score board and you want to make it roll like a pinball machine, where instead of just adding 1,000 points for something, it adds some fraction of points until it reaches 1,000, you do that sort of thing on tick. Updating a timer on screen, do that on tick.

The health of every entity running that script is getting checked every tick whether it changes or not. Using events and event handlers is way more efficient for this sort of thing. For what you have in your current script, a better way would be to just check the health at the end of the hit, and if it’s 0 or less, destroy the entity.

@WashedUpStudios

HitPoints2.zip (108.0 KB)

See the above zip. It has four slices and four script canvases. This is a way to use collision events.

Place the spawner slice in a level (it’s just a marker, it has no mesh).
Place the player slice facing the spawner about 20 meters away and maybe 4-5 meters in the air (it has a camera, no mesh).

Hit play.

The spawner will eject a cube every second with a random number of hit points, 1-3. Each cube will show how many points it spawns with. Each time a cube collides with an entity with a projectile tag, it loses a point and displays its hit points. At 0 hit points the cube is destroyed.

The player camera fires a sphere projectile every 0.2 seconds that can live for two seconds. If the projectile hits a few entities with an enemy tag, it’s destroyed.

The spawner and fire script canvases both use OnTIck. In a game I wouldn’t do this, just doing it to automate the spawning of many cubes and projectiles.

Edit: This little demo can reach a point where there are too many collisions happening. Turning on Continuous collision detection in the PhysX Configuration tool helps.

1 Like

@WashedUpStudios I believe the problem is that your Script Event “Gun Hit” does not have an address type, this makes this Script Event broadcast to every available handler. You should specify an Address Type of EntityId on the Gun Hit Script Event, then in your Script Canvas graphs each of your Script Event handlers will connect to the entity that owns it. When you send the Script Event, you will need to specify the EntityId of the entity that got hit.

3 Likes

Hi Thank you all for helping out on this problem! :+1: But I have finally figured it out, I did use @microAMZN’s files as references and built a new system with rate of fire for different guns, different health per enemy spawn (help from microAMZN), and now have a working health system. Thank you all for the help on this issue.

1 Like