Problem with loot spawning at 0.0.0 location..

I added some weighted rng loot drops to my game but for some reason i can’t make it spawn where my enemy die. I have the loot functions on an actor component then by adding the actor component to my base enemy BP seems to work pretty well. The loot drops as i set it only not on the location on which it is set (location of the enemy).

It looks like this on the actor component

I was trying to get world location or actor location from there to my base enemy bp but it didnt work. I had some success on putting the drop logic directly on the enemy bp but the rng loot didn’t work… Can i somehow get the location of the mesh of the enemy bp or capsule component and use that as a drop location on this actor component somehow? I awso try to "set the location " in the enemy bp and then getting it on the actor component but the loot aways just drop at 0.0.0 location :frowning:

Is by any chance the Destroy node executing before DropLoot?

No it is not :frowning:

Maybe i do not access properly the enemy base bp from the actor component where i try to get the location ?

Where / how are you assigning a value to MainEnemy?
image

Is just a reference to my main enemy bp. From which all my enemy’s are child of. Not sure what else to do. I was trying to SET a capsule or mesh location on this base enemy bp and then was getting this location on the actor componenent but it didnt work…

When i print string the world or actor location of this main enemy bp i get 0.0.0

Yes, got that. It must be set somewhere.

I assume LootTable is a component assigned to BP_MainEnemyClass. Right? So there should be a GetOwner → Cast<BP_MainEnemyClass>() → MainEnemy in BeginPlay.

GetActorLocation node returns a zero vector if the reference is null. So we need to check if its being set correctly before anything else.

yes this correct…

Where exactly do i need to cast to main enemy bp ? On beginn play in the actor component ?

Yes.

:point_up_2:

Hmm im not sure if this is right but its working still have 1 bug with it. It picks only 1 actor when i have 10 and spawns all the loot only on this one actor… I guess my setup isnt right yet…

Here is how this looks like when i have many enemy’s and by killing them all the loot drops only on the 1 guy and stacks on him…

This:

I try that but it didn’t work … i get an error on the owner

then i can plug the main enemy there and the error is gone but the loot start spawning again at 0.0.0

The node should say Target is Actor Component not Target is Actor:
image

Make sure you add this in the LootTable component.

1 Like

Oh yeah i didnt see that. Just changed it to “owner” actor component and now everything works as it should :sunglasses: lol… Thx that was pretty easy acctually

1 Like

Great!

Now that its working, if all you want is the actors location you can delete all the above :innocent: and just do:

If you need to access anything specific to a class then you do need to cast.

1 Like

lol yeah even this works now :joy:… I previously did exactly this as the very first thing and it didn’t work. But i had “get owner actor” and not “owner actor component”. That would have fixed it from the beginning. Oh well now i learned something new so hopefully i don’t make this mistake again. Thx a lot :wave:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.