Download

Can the player call a function on a blueprint?

I want to create a small world with many doors and one player. Whenever the player gets within 100 units of a door, it should open, so I’ll make a door blueprint with a sphere component of radius 100 with its collision set to OverlapOnlyPawn.

I could approach this two ways that I can see. One, in the door’s Event Graph I could open and close the door with EventActorBeginOverlap and EventActorEndOverlap. This seems reasonable as long as I’m fine with any pawn opening the door. But if I wanted only the player character to open doors, I think I would have to get the player character on EventBeginPlay, which seems like bad form when I have hundreds of instances of the door blueprint.

As another option, I could have the door-opening functionality on the player character blueprint, and functions on the door blueprint called OpenDoor and CloseDoor. When the player overlaps something, it checks to see if it’s a door. If it is, the player blueprint calls the OpenDoor function on the door blueprint. Is this a possibility? I don’t know how to check if I’ve hit a door or how to call a function on the door.

The devs have made an official walkthough of blueprints on youtube:- YouTube
They will show you how to do with a light what you want to do with the door. :slight_smile:

it is more simple, the door`s trigger can check if the pawn is the player.