Donitzo / godot-simple-portal-system

A simple portal system for viewport-based portals in Godot 4.
Creative Commons Zero v1.0 Universal
64 stars 8 forks source link

How to actually trigger the "teleport"? #2

Closed brunohilt closed 9 months ago

brunohilt commented 9 months ago

Hi, I've been playing around with this plugin and it works great, so thanks for making it, first of all!

I'm running into an issue, however, where I can't seem to actually figure out how to trigger the behaviour seen in the demo scene, where walking through a portal transports you to the other side of it.

I've been going through the demo scene quite thoroughly, but for some reason am unable to find the bit of behaviour that causes that transportation. I know it has to do with the portal.gd's real_to_exit functions, but I can't see anything where, in the demo scene, they interact with the player.

Am I missing something obvious? I'm not that experienced so I may just be blind to some obvious solution somewhere.

Thanks a lot in advance!

Donitzo commented 9 months ago

The teleportation code in the demo is moving the player to the opposite side of the Z axis and is found in player.gd:

if abs(position.z) > 7.1: 
    position.z -= 7.1 * 2 * sign(position.z) 

How you implement the teleporting depends on how your level layout works. You could for example add a trigger zone after the portal which teleports the player as it enters. This could for example a box-shape where one side of the box is flush against the portal surface in (Z).

brunohilt commented 9 months ago

Ah! Okay, thanks a lot! Didn't realize the teleportation logic was to be handled outside of this asset.

Good to know — and thanks again for making this. Very useful tool.