0 votes

I have tried attaching a StaticBody2D to my camera but that doesnt work and i tried making a wall that moves if the player is pressing right but that does work the way i want it to. How do i make an invisible wall that is always on the left of the camera.

in Engine by (399 points)

Do you have anymore details on what you did to try the staticbody solution?

I have tried attaching a StaticBody2D to my camera but that doesnt work

Why not? Works fine for me.

i tried making a wall that moves if the player is pressing right but that does work the way i want it to.

Why not? How do you want it to work then?

2 Answers

0 votes
Best answer

So i found a better solution i get the end of my canvas transform get_canvas_transform() then get the position on the end of my canvas to the origin

func _process(delta):
var ctrans = get_canvas_transform()
var min_pos = -ctrans.get_origin() / ctrans.get_scale()
position.x = min_pos.x

i got the code for finding the camera end position from this question https://godotengine.org/qa/13740/get-camera-extents-rect-2d

so now instead of checking if the player is in the area2D for the wall to move the wall will just move if the camera moves.

by (399 points)
selected by
0 votes

So I managed to make the camera move with an invisible wall behind it i just made a camera2d with an area2d and staticbody2d and made a script that move the camera2d pos.x if the player is out of the area. Not sure if it is the best solution to my problem but it works.

by (399 points)
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.