Trying to adapt Godot 3 code to Godot 4.
Trying to get the intersection with the ground, intersect_ray only accepts one argument, not two. Code below:
extends Node3D
var ray_origin = Vector3()
var ray_target = Vector3()
var mouse_position = Vector2()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
mouse_position = get_viewport().get_mouse_position()
ray_origin = $"Character Controller/Camera3D".project_ray_origin(mouse_position)
ray_target = ray_origin + $"Character Controller/Camera3D".project_ray_normal(mouse_position) * 1000
var space_state = get_world_3d().direct_space_state
var intersection = space_state.intersect_ray(ray_origin, ray_target)
if not intersection.is_empty():
var pos = intersection.position
Parse Error: Too many arguments for "intersect_ray()" call. Expected at most 1 but received 2.