GetCapsuleComponent uses an invalid target

I want my Player Controller to do the following: when left clicking on actor TriggerBox, if it overlaps with pawn CameraPlayer, deactivate collision. But when I try to compile, I get the following error:

Cast node always need an input object. This object will be casted to your class…
If this is PlayerController BluePrint and your default or possessed pawn is Camera player, try GetControlledPawn node because get controlled pawn node will give back the actuall possessed pawn :slight_smile:

From that maybe you can cast and use your other code. (And dont forget cast nodes always need execution pin too “white line”)

Ok, I think I understand now. I thought a cast node could act as a reference (like in a level blueprint), so I didn’t think it needed an input object and to be executed.

Unfortunately, your solution doesn’t work, because I need a way to reference ALL CameraPlayer pawns in the level, not just the one being controlled by the player. Any ideas how I could do this?

Edit: Perhaps I should try a more simple approach. Instead of having the actor disable collision only when overlapped by a certain pawn, it should do so when overlapped by anything at all. That would still work for me. Something like this:

When cursor is over actor TriggerBox, if the actor is overlapped by anything, deactivate collision. Could this work?

“I think you need to re-think your code, if the idea is that you want to know if any camera is overlaped.”

Please ignore the names of my actor and pawn; I’ll have to rename them eventually. The pawn is a playable character, and the actor is just a static mesh. The idea is that if the pawn overlaps the actor, the actor deactivates collision until the pawn has moved away and is no longer overlapping.

Read the message again.

The Cast To Node is not executed (The Arrow Pins are not connected)

I think you need to re-think your code, if the idea is that you want to know if any camera is overlaped.

There is a method for collisions that will returrn all of the overlapped componets, don´t use a trigger for this, trigger is just to turn on and off, I think you should use a collision box.

When the collision is overlapped, you could ask for the method “getOverlappingActors” or “getOverlappingComponents” (the last will provide exactly the component (camera) that is overlapping, actors will return a type (like your FirstPlayerBlueprint).

With that method, latter you could create a foreach, filter by type and do whatever you need…

Hope it helps