when attaching 3rd person camera to player, only the camera rotates, player stays still

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kiwoneedsassistance

I watched a very informative tutorial on this ball player controller, and then i went and found a really good 3rd person camera controller w/ a h/v parent system, they both work great on their own, but when i put the clipped camera under the player controller to connect them, the player doesn’t move or rotate, but the camera rotates all around when i try to move. can anyone help me with this? i just want a 3rd person camera to follow my ball around, but now my ball won’t move :frowning:

here’s the scripts:


extends RigidBody

var movement_input = Vector3()

func _ready():

func _physics_process(delta):

if Input.is_action_just_pressed("r"):

func process_input(delta):
movement_input = Vector3.ZERO

if Input.is_action_pressed("move_forward"):
	movement_input.z -= 1
if Input.is_action_pressed("move_back"):
	movement_input.z += 1
if Input.is_action_pressed("strafe_left"):
	movement_input.x -= 1
if Input.is_action_pressed("strafe_right"):
	movement_input.x += 1

movement_input = movement_input.normalized()

func process_movement(delta):
apply_impulse(Vector3.ZERO, movement_input)


extends Spatial

var camrot_h = 0
var camrot_v = 0
var cam_v_min = -55
var cam_v_max = 75
var h_sensitivity = 0.1
var v_sensitivity = 0.1
var h_acceleration = 10
var v_acceleration = 10

func _ready():


func _input(event):
if event is InputEventMouseMotion:
camrot_h += -event.relative.x * h_sensitivity
camrot_v += event.relative.y * v_sensitivity

func _physics_process(delta):

camrot_v = clamp(camrot_v, cam_v_min, cam_v_max)

$h.rotation_degrees.y = lerp($h.rotation_degrees.y, camrot_h, delta * h_acceleration)
$h/v.rotation_degrees.x = lerp($h/v.rotation_degrees.x, camrot_v, delta * v_acceleration)
:bust_in_silhouette: Reply From: Kiwoneedsassistance

turns out i just had to go to the ball’s rigid body and switch it to character lol,
but now i gotta figure out how to move in the direction the camera is facing ;/

:bust_in_silhouette: Reply From: sairavmondal

Here is an example of a camera movement script in Godot Engine using GDScript that keeps the player centered while allowing them to move around:

extends Camera2D
var target : Node
var smooth_speed = 0.125
var offset = Vector2(0, 0)
func _fixed_process(delta):
    var desired_position = target.position + offset
    var smoothed_position = desired_position.lerp(position, smooth_speed)

You can use this script by attaching it to your camera object and setting the “target” variable to the player object. You can adjust the smooth_speed variable to change the speed at which the camera follows the player, and the offset variable to set the distance between the camera and the player.

You can also add some constraints on the movement of the camera depending on your level design or other requirements of your game.

This script uses the _fixed_process() function to update the camera position in every frame. This can be useful for controlling camera movement in a physics-based game, or for ensuring consistent movement across different frame rates.