Files
godot-demo-projects/3d/ik/target_from_mousepos.gd
Christen Lofland 7e2a55aa07 3D Inverse Kinematics Godot 4 Conversion (Partial) (#1036)
* These changes allow the project to start and run in Godot 4.2

I hit some of the files with my formatter, if whitespace updates are not wanted I can remove those.
The project doesn't entirely work yet, but it runs. I am still working on making it work properly fully, but at least it starts now instead of crashing.

* Center text to match Godot 3 example better.
2024-08-27 05:13:54 -07:00

20 lines
386 B
GDScript

extends Camera3D
@export var MOVEMENT_SPEED: float = 12
@export var flip_axis: bool = false
@onready var targets = $Targets
func _process(_delta):
var mouse_to_world = (
project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
)
if flip_axis:
mouse_to_world = -mouse_to_world
else:
mouse_to_world.z *= -1
targets.transform.origin = mouse_to_world