Linetrace + collecting objects

Hello friends,

As beginner developer, I am begging for your help with my small problem. I believe for you, it won’t be that hard as for me. I am trying to create small simple game, based on collecting keys and batteries (for now) . My problem begins when I try to collect battery for flashlight. Everytime when I try to collect battery, something weird happens. I placed 2 Battery actors and when I try to collect it one, it will not collect that one, but actor of that class with last index, if you understand what I mean. I don’t know why it happens because I am using “get actor of class” not “get all actors of class” …

​In the picture you can see how I wanted to use collecting objects. “GetClass” node goes from linetrace. After clicking left mouse game checks if class, which was hitted by linetrace is the same as class Battery Add, if yes, then check if battery is below 100% and then I will get that class, add energy and destroy actor… that’s all… i don’t know where I made mistake. so… Please, if you will find your time, help me…

Thanks for your time and enjoy Unreal Engine.

You already have a reference to the actor in the line trace break node, which is where you’re getting the class from. You don’t need GetActorOfClass, just use the reference from the line trace.