Move character to objects (Actors) and interact

I have 4 types of object to interact with player.
Door(to move from scene to scene)
Boxes(to find loot)
Mobs(For Battle)
NPC(For Talk and trade)

Im using standart TopDown controller.
I need to explain to my character what to do with all this objects.
For example.
When i need to use door to go to another level. I aim to door and click it. character moves until it will hit it and new level loads.
When i need to hit a Mob. Player shoud firs approach to him than hit
Witch construction will be better?![alt text][1]

I think you have two options. You either set up an ‘OnClicked’ event in each of your interactable object class and you respond to those events accordingly, or you use type casting after doing a line trace on the mouse click and analyzing the hit result.

If you only have four interactable object types I’d go with the first option.
Let me know if you need further explanation.

The move is correct, you need to implement a distance to the selected actor, once it is <= you attack.

however, if you want to do something generic for each kind of object, you require the use a BP Interface.

Add the INTERFACE to both Controller and object.

Once youre close to your object, execute interact CALL to the actor.

To implement this on your object, just add the event: (you can do what you want, such as open a level or even attack if it is enemy)

Hope this help you on something!


I’m glad that you could get it working. First, let me answer your first question: drag a wire from your sphere collision object reference, and search for ‘get overlapping actors’. This function will return you an actor array containing all actors that are currently overlapping your sphere collision. You just have to iterate through that array using a ‘ForEachLoop’ and check every element by type casting if it as a door, enemy, etc and act accordingly.

Your Blueprint setup seems more or less fine, however I have a few suggestions. I noticed that two events can execute the same ‘Open Level’ node which is fine, but I encountered some issues with similar setup in the past, so I suggest you to use two separate ‘Open Level’ nodes instead for both events.

Another thing I noticed is that you have set your ‘CursorOverDoor’ variable to true in both cases (start overlap-end overlap), which might be just a small mistake.

Generally I would say that your setup is okay, and could work, but it isn’t the most efficient solution and it might be difficult to expand/improve the functionalities later. In my humble opinion, Blueprint Interfaces would be a great solution to your particular issue. You could create an ‘InteractWithPlayer’ interface function, implement that interface to all of your interactable classes, and implement the functions there. This way, you would only have to call that one function when the player interacts. Here is an introduction to BP Interfaces, if you are not familiar with them: link text

Hope this will help you a bit.

Thanks for answers guys. I manage to do this with using check sphere collider.
Now i have a two questions.
1)Is it good blue print or could make it simpler?
2) how i can make checking if player inside sphere collider? Right now if he standing next to door nothing happend.