Godot Version
4.6
Question
I try to rotate the camera but its not going upside down. I try a lot of things that is why its mostly empty because my game uses a way to walk on the ceiling and more will come but i cant find a way to rotate the Player and camera at the same time its mostly empty. Because i want that the camera works first then i can add the other sides to walk on can some help?
extends CharacterBody3D
@export var speed = 5
@export var jump_velocity = 5
@export var Look_sensitfity = 0.01
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@export var Gravity_direction = 0
@onready var camera:Camera3D = $Camera
@onready var player = $"."
func _physics_process(delta):
var input = Input.get_vector(“left”, “right”, “forwards”,“backwards”).normalized() * speed
if is_on_floor():
if Gravity_direction == 0:
if Input.is_action_just_pressed("f1"):
Gravity_direction = 1
print("je gaat opzekop")
if is_on_ceiling():
if Gravity_direction == 1:
if Input.is_action_just_pressed("f1"):
Gravity_direction = 0
print("Normale zwaarte kracht")
if Gravity_direction == 0:
velocity.y -= gravity * delta
velocity = input.x * global_basis.x + input.y * global_basis.z + Vector3(0, velocity.y, 0)
if is_on_floor or is_on_ceiling() or is_on_wall():
if Input.is_action_just_pressed("jump"): velocity.y = jump_velocity
else: velocity.y -= gravity * delta
move_and_slide()
if Gravity_direction == 1:
velocity.y += gravity * delta
velocity = input.x * global_basis.x + input.y * global_basis.z + Vector3(0, velocity.y, 0)
if is_on_ceiling() or is_on_floor() or is_on_wall():
if Input.is_action_just_pressed("jump"): velocity.y -= jump_velocity
else: velocity.y += gravity * delta
move_and_slide()
func _input(event):
if Gravity_direction == 0:
if event is InputEventMouseMotion:
rotate_y(event.relative.x * -Look_sensitfity)
camera.rotate_x(event.relative.y * -Look_sensitfity)
camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)
if Gravity_direction == 1:
if event is InputEventMouseMotion:
rotate_y(event.relative.x * -Look_sensitfity)
camera.rotate_x(event.relative.y * -Look_sensitfity)
camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)