Gilli
Gilli

Reputation: 1

How can I change a blueprint in UE4 from on collision to on interact?

I created a teleporter asset for my game in the UE4 engine. As of right now for the teleporter to work all's the player has to do is run up to the teleporter and make contact with it and it'll teleport them to a different room. I now want the teleporter to only work once the player presses "E" on it and have it no longer activate on collision. I'm new to UE4 so any help with this would be greatly appreciated, thank you!

Upvotes: -1

Views: 739

Answers (1)

Leonardo Bonadimani
Leonardo Bonadimani

Reputation: 3

You can create a boolean variable "canTeleport" inside the playerCharacter blueprint and set it to false.

You then add a collisionBoxComponent to the teleporter actor and set his collision profile to "OverlapAll".

Then you can add the event "OnComponentBeginOverlap" on the teleporter collisionBox and cast to the playerCharacter blueprint. After the cast you can set "canTeleport" to true.

Then add an event for keypress "E" inside the playerCharacter blueprint that checks if "canTeleport" is true, then it teleports the player.

Remember to add the "OnComponentEndOverlap" event on the teleporter blueprints that sets "canTeleport" to false

Upvotes: 0

Related Questions