Reputation: 51
I have a simple side-scrolling platformer where the player is a ball, and I want him to rotate as he moves to look like he is rolling.
However, I have a 2D Camera set up so the player is at the bottom center of the screen. I want the player to stay there, but when I move the player the camera moves in circles along with the player.
How can I stop the camera from moving around?
Upvotes: 1
Views: 1654
Reputation: 40170
A few options come to mind:
PhysicsBody2D
(e.g. a KinematicBody2D
) with a Sprite
or similar. And the Camera2D
is a child of the PhysicsBody2D
. Well, rotate the Sprite
. That way the rotation does not affect the Camera2D
. Of course, if the rotation is driven by physics, then this option isn't helpful.Camera2D
be a child of your PhysicsBody2D
to make it follow it. Instead, you can use a RemoteTransform2D
that pushes its position (with update_position = true
), but not its rotation (with update_rotation
= false) to another Node2D
. And then you make your Camera2D
a child that another Node2D
.PhysicsBody2D
at all. In that case, you can try a PinJoint2D
. Set your node_a
to the character PhysicsBody2D
, and your node_b
to some RigidBody2D
, and then the Camera2D
can be a child of the RigidBody2D
.Node2D
and on its _physics_process
you have it copy the global_position
of your character to its own global_position
, so that it follows it. Then make the Camera2D
a child of the Node2D
.Upvotes: 1