Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Skydome |
I have two players. Camera is attached to player 1. When player 2 goes out of camera view I want to print(“out of bounds”). It’s a 2D game with camera2d node.
How should I go about doing that?
Have you tried checking the root Viewport
’s boundaries against the second player’s position? For example:
# Do this check when the second player moves.
if player2.position > get_tree().get_root().size:
print("Player 2 is out of bounds.")
I don’t know whether this will work, but it’s a start.
Ertain | 2022-06-24 23:39
Thank you! But what if camera is zoomed out. I guess I will have to do some adjustments.
Skydome | 2022-06-25 09:54