This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Path2D/PathFollow2D - Camera2D

As you can see, I have a Camera2D following the Player, and I also want to have the Path2D/PathFollow2D staying outside of the camera viewport, such that NPCs/enemies can spawn outside of view before coming into the fray.


I have tried placing Path2D/PathFollow2D as a child of the Camera2D node, but it remains static and NPCs are spawning from the same place.

How can I make the Path2D/PathFollow2D follow the camera and remain outside of the viewport?

Godot version 3.5.1
in Engine by (27 points)

in code set the vector/location of the object to some offset of the camera.

cameravector + offsetvector.

Thank you for the suggestion. I want to achieve a consistent boundary around the camera, such that it is always outside of the viewport. Wouldn't I have to calculate the camera's position relative to the world map, and then select a random position based on that?

Shouldn't have to, no. You should just be able to use the camera's .translation to get the position of the camera. Pretty sure it stores this variable as a reference to it's location in "space"

I cannot find "translation" as either a property or a method in Camera2D's documentation.

You should be parenting your camera to a kinetic body node. The camera doesn't have a translation variable.

set it's parent to a kinematicbody2d and then use that to move the camera instead.

This was already the case. The issue wasn't having the camera follow the Player body, but to have NPCs spawn outside of the camera viewport. It's moot now, as I've created a custom solution via script. Thank you for responding to my questions, though.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.