Get access to parameters of a certain Actor in an array

In my game I have a lot of destructible actors.
Each time that I press “Left Mouse Button”, a mental force (simulated by a ray trace) is shot.
If the ray trace hit a destructible item with the tag “MentalDamage” then I want to access to the components and parameters of this precisely Actor (like activate a RadialForce situades inside it).

How can I do it? maybe using arrays? I don’t know what to do

If you are already tracing, it could not be easier than:

Yes, that’s my setup which already works, but I need to know exactly what is the hit actor and then access it.
It’s like to filter an array of different actors and then branch after branch knowing exactly the instance of the hit actor. is it possible?

HitActor IS the instance of the actor. :slight_smile: Cast it to the expected actor class and you’ll have access to its variables and functions.

Yeah, I think that i was missing exactly the cast to the expected actor class. I will try :slight_smile: For now, thanks for your help :smiley:

Good stuff. Please consider marking this issue as resolved providing everything works as expected.

I can’t find a way to get the actor variables by casting to the class / getting the array. I feel so dumb…

If I don’t ask to much, can I ask you to post a blueprint image with a sample where: after hitting an actor, you get some variables (bool/integer/Float) from the same actor (through casting to the class / array)?

You must be really close.

If it does not work for you, but a print node in CastFailed in case you’re not hitting the right object.

This helps so much! So, in theory I can put more CastTo Node after another in case I didn’t hit the right object until I reach the CastTo to the right object. I mean, I can use the CastTo node like if was a branch node.

[…]can use the CastTo node like if
was a branch node.

Yeah, you absolutely can. Although, the code may turn into spaghetti if you end up with 10 cascading CastFails. There are many ways of identifying objects. For example, here’s a method that is using ActorTags:

Every Actor has Tags array. You can define them in the editor, in object’s ClassDefaults; as many as you need. You can also add and remove them during run-time, altering the way your trace treats the object.

1 Like