Getting distance to center of trigger?

How can I get the distance to the center of a trigger from the player with blueprints? Using this doesn’t seem to do anything.

Sorry, the radiationsphere is a separate blueprint from the player and is placed in the world, so Im trying to find the distance from the player to the center of the sphere when the player is within it.

You are not casting anything. You used the “Cast to radiationSphere” but the Object you use to cast is empty.

If it’s a component of this actor simply input it in there. Otherwise please tell me where the radiationSphere should come from and how you try to get it so I can give you a direct answer and don’t have to guess :wink:

Cheers

Is it possible there are multiple once?

…well it kinda doesn’t matter. If you can overlap multiple once you will need an array and check each.

You need a variable to hold them. You create an “Event begin overlap” and cast that to your radiationsphere. If it’s successful you save it in your variable (you will have to remove it on “event end overlap”).

If your variable is valid you run the snippet you showed in your start post and input the new variable into the cast node.

That should do the trick :wink:

I think my casting is the issue. This is located in the player blueprint, so what object would I cast to?

http://i.imgur.com/fteNOrU.png

No the “cast to” is correct.

However you need an object as reference. This mustn’t be empty otherwise you will always get null as result. By that I mean you need something in that “Object” pin.

What you need is a reference to the currently overlapping radiation sphere.

The easiest way is to store it whenever you begin to overlap (“Event begin overlap”).

You could also do it via a “Get all overlapping actors” but the result there is an array and you may or may not need that. Especially on event tick this can get quite expensive.