Pulling object to the player when holding Left Mouse Button

I’m trying to set up a mechanic in my game where the player can use Left Mouse Button to pull an object towards them upon holding Left Mouse Button. I’m using a cone mesh that if an actor enters and they have the tag vacuumable they can be effected by the mechanic. The reason for the cone is because I want it to be a Cone Trace (which doesn’t exist) and using Sphere Traces just doesn’t work for me, so until Epic adds a Cone Trace that’s not changing. I tried following this tutorial to the best I could for the pulling of the objects but I think I messed something up. This has to work with AI as well since I want to be able to also pull AI towards the player with this and have them try to struggle to escape from the player.

Here is my code:

Update I got it half working but I now have an error coming up and the AI character keeps falling over, there is also the problem that if multiple items are in the cone it only pulls the last one that entered the cone

error: Blueprint Runtime Error: “Accessed None trying to read (real) property VacuumableObject in BP_ThirdPersonCharacter_C”. Node: Add Impulse Graph: EventGraph Function: Execute Ubergraph BP Third Person Character Blueprint: BP_ThirdPersonCharacter

1 Like

Make it an array.(Soft-Reference for good practice)

Add unique and remove from the array.

1 Like

Thank you that worked, new thing I had to learn and still don’t understand fully but that worked, also figured out my other two problems in the process to (changed the Impulse to a VInterp which got rid of the error and the use of the AI falling over). Also what is the point of the branch at the end of the ADDUNIQUE?

AddUnique returns a index(int), if the index is -1 that means it was not added. The index is also used when use Get() from the array to get the element directly.
The AddUnique = -1 branch itself acts like the Remove returns a bool.

1 Like

ah okay that make sense