|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Newby |
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.
Do you have anymore details on what you did to try the staticbody solution?
RedBlueCarrots | 2020-05-25 07:26
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?
njamster | 2020-05-25 10:23
|
|
|
|
Reply From: |
Newby |
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.
|
|
|
|
Reply From: |
Newby |
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://forum.godotengine.org/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.