Invalid access to property or key 'global_transform' on a base objekt of type null instance

Godot version:
v4.3.stable.

So i’ve been following a youtube tutorial and got an error on the player movement script.

This is the code and the highlightet part is causing the trauble (I think so):

func _physics_process(delta: float) → void:
var on_floor = is_on_floor()
if !is_dying:
if !on_floor:
vertial_velocity += Vector3.DOWNgravitiy2delta
else:
vertial_velocity = Vector3.DOWN
gravitiy/10
if Input.is_action_just_pressed(“jump”) and (!is_attacking) and on_floor:
vertial_velocity = Vector3.UP*jump_force
angular_acceleration = 10
movement_speed = 15
acceleration = 15
var h_rot = camrot_h.global_transform.basis.get_euler().y
if (Input.is_action_pressed(“forward”) || Input.is_action_pressed(“backward”) || Input.is_action_pressed(“left”) || Input.is_action_pressed(“right”)):
direction = Vector3(Input.get_action_strength(“left”) - Input.get_action_strength(“right”),
0,
Input.get_action_strength(“forward”) - Input.get_action_strength(“backward”))
direction = direction.rotated(Vector3.UP, h_rot).normalized()
if Input.is_action_pressed(“sprint”) and (is_walking):
movement_speed = run_speed
is_running = true
else:
is_walking = true
movement_speed = walk_speed
else:
is_walking = false
is_running = false

camrot_h is null (is not set). Maybe you mean:

var h_rot = global_transform.basis.get_euler().y

or

var h_rot = $camrot_h.global_transform.basis.get_euler().y

The first one it was, now the game starts and the camera workes without any errors, but as soon as I move the player it flys away and the screen turns gray. I’m gonna follow the rest of the tutorial and see if I can get it fixed by myself.

Either way thank you so much! theres no way I’d have figuered this out by myself.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.