One way collision in 3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SupToasty
:warning: Old Version Published before Godot 3 was released.

How could i make a ray shield like in halo and portal, where players can enter on one side, but can not re-enter on the other side? Also bullets and throwables should not be able to enter on either side. I was thinking a kinematic body would work, but I don’t know how to type this up in gdscript. Thanks for your time.

:bust_in_silhouette: Reply From: Zylann

You can add a script that monitors bodies entering the portal, then enable a collider once it is crossed so the player cannot go back. To know which direction, you can place a trigger on the side you want.

If you want throwables not to go through, just put them on another physics layer and play with the collision mask of the gate so only what you want gets blocked.

Sorry I don’t have the code for this, at the moment I only made starship gates in 2D but it should be easy to do what you want it 3D as well. Take a look at the doc for the scripting part: http://docs.godotengine.org/en/latest/tutorials/2d/physics_introduction.html
(it’s for 2D but 3D is similar)