+2 votes

is it possible for camera2d to stick on path2d while following relatively to player's position?
if so, how to achieve it?
something like this:
the illustration of what I want to do
in this illustration, the player is off-center from camera on x-axis, but centered on y-axis because the camera sticks in the path


the reason behind is because I want to move my player on not straight room and I want to fix a camera on certain axis on certain sections (like move only on x axis on straight right room).
at the moment I have no idea what to do other than changing camera's limit and detect using area2d per sections to change the limit, but it's not good enough as intersecting areas wont be able to get transitioned smoothly. the camera will snap into other section after going little bit far from the current area

Godot version v3.4.4.stable.official [419e713a2]
in Engine by (17 points)

Interesting question. Yes, you can try to stick camera to the Path2D, but there is another approach: Making a camera KinematicBoby and set up StaticBody boundaries. Note, that collisions shoud be set on another layer.

  1. so any idea how to make camera sticks to path while following player too?

  2. is there a difference between using Tilemap as a static collision and StaticBody? also using this similar method, if it's too tight to camera, it wont move at all. but making a gap for the KinematicBody to move will show the area i don't want to get shown

  1. Somehow find the closest point to the player position on path. Sorry, can't give realisation
  2. Yes, TileMap will also work. Yeah, that might be a problem. The possible solutions is making really small gap or just paint out of bounds area with black (as it done in Undertale) or make something like background. Also note that at different screen ratios the camera can have different sizes, so you shoul add background.

alright thanks for the respond
yes, adding the filler like background or just fill with tilemap is the way for KinematicBody method. but my problem is having those areas
shown at all. i want to have it tight and only show certain areas, but i guess it's too much for that node since the camera can get weird if it hit by some collision while trying to positioned itself to player

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.