Only one copy/instance of actor setting variable in different BP.

I have an actor that sets a variable (in my Third Person Character BP) true when overlapped, and false when not overlapped.

In my Third Person Character BP, I have a print string to check if the variable is set.

TPCBP

I have two copies of this actor in my level. Only one of them sets the variable.

Does anyone know how to make all copies/instances of the actor set the variable?

Using event tick with a get actor class is pretty exepensive.

Try to use these event instead:

If you have spawn your 2nd character from the game mode, you can store it variable and from your character bp, call GetGameMode > (your 2nd character) > set variable.

Or with a GetActorsof All class (expensive)
image

I have considered using begin overlap but I prefer using the method shown in case of actors starting overlapped or having conditions reset while overlapped so as not to require another overlap ‘beginning’.

My problem does not involve the use of a second character.

I tried using two different interface functions to set and unset the variable in the character BP and this still did not work.

Actor BP:

Third Person Character BP:

The problem remains to be that only one copy of the actor is setting the variable to true and allowing the ‘YES’ print string to fire.

Actors

Thank you very much for your suggestions but I still seem to be without a solution to this problem.

EDIT: I also tried casting to my Third Person Character BP but this does not work either.

The node GetActorofClass, will return only the first instance of your character bp.

If you have ThirdPerson_0 and ThirdPerson_1 on the level map, it will only return ThirdPerson_0.

So you can either do a GetAllActorsofClass and loop them or a way to presave the variable actor of your 2nd character (ThirdPerson_1) such as spawning it.

I only have one Third Person Character.

The problem is that the variable is only getting set when I overlap one of the sphere collision actors.

I would like all copies of the actor with the sphere collision to set the variable.

You have:
x1 Class BP - Third Person Character which represent a file asset in your content browser and can be seen as something not yet alive.

x2 Actors - Third Person Character which are objects alive in your memory, if you look in your outliner, it have a suffix index like _0 , _1 , _2 etc…

try with the GetAllActorsOfClass which will return of copy(actors) of your specific class bp.

I do not have multiple copies of my third person character in my level.

I am trying to interact with two copies of a different actor by overlapping with them.

My problem is that only one of the actors I’m trying to interact with is setting the variable in my third person character BP.

That’s a weird way to go about a healing zone.

In the healing actor use Begin and End overlaps to call the BPI events on the pawn.

In the pawn set a bool or enum state (preferred) when the healing starts/ends.

Use the state on tick in pawn to print.


The healing zone (actors) only job is to call the healing events. Nothing else should be in that class. More so the collision component should only trigger overlap events when a pawns capsule component overlaps it.

Using a BPI and setting up your collisions correctly mitigates the need to cast to class. does implement interface is the only condition that needs to be met.

Working model…

Blueprint Interface [ BPI_Healing ] with 2 Functions (HealStart, HealStop)
Only added to the character class.

HealZone actor, Overlap collision w/custom collision settings to only overlap PawnCapsule.

HealZone event graph, Overlap (Begin/End) implementation


Character class…

Add an enumerator for healing state.

Implement the Healing Start/Stop events and Hook up Tick event printing.


1 Like

Thanks for figuring this out for me. I will try to reproduce it myself. Although it does seem similar to what I tried, hopefully I can find out why yours works and mine didn’t.

Thank you again very much. It does seem like a good working solution.

EDIT: I am really just confused because my attempt did work as intended, but only for one copy of the healing zone actor. All the copies performed their own logic(print string) but only one would set the variable in the Third Person Character BP.

UPDATE: It seems to work well enough now.

  1. The Begin and End overlaps seemed to be the biggest fix here as I continued to have the same problem when using my original (is overlapping node[on tick]) method.
  • My only guess as to why this is happening is that only the original sphere component is being counted for the overlap and any copies are being counted as different components. Apparently the behaviour is different with the begin/end overlap nodes.
  1. I did create a new Object Response Channel for PawnCapsule, but I think there must be some more setup that I’m unaware of to actually make it sense the pawn capsule.

  2. When I hit play, the print string fires as Healing even though nothing is overlapping the healing zone. (Collision settings are set to ignore everything except Pawn which is set to overlap)

  • I fixed this by setting the enum to ‘not healing’ on beginplay.
  1. The Switch Has Authority node. It only works when I drag out of the authority pin, not remote.

Other than those differences, I do think this will be a good enough solution for now.
I can foresee problems with needing to rely on the begin/end overlap nodes, such as spawning on the healing zone possibly not triggering a begin-overlap and disabling the healing zone while overlapping may require an additional overlap to reset healing to ON, but I can address that potential issue if it does ever present itself.

Thank you very much to everyone for helping with this.

UPDATE#2: I got my original method working. The problem was that I was using a for each loop to cycle through the healing zones. I needed to use for each with break.

Thank you again everyone for the support!

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