Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
here’s the scripts:
PLAYER SCRIPT
extends RigidBody
var movement_input = Vector3()
func _ready():
pass
func _physics_process(delta):
process_input(delta)
process_movement(delta)
if Input.is_action_just_pressed("r"):
get_tree().reload_current_scene()
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
print(movement_input)
movement_input = movement_input.normalized()
func process_movement(delta):
apply_impulse(Vector3.ZERO, movement_input)
CAMERA SCRIPT
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():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
$h/v/Camera.add_exception(get_parent())
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)