Created
April 20, 2019 02:47
-
-
Save WolfgangSenff/852160e4847afa6cd7008960b72c8f86 to your computer and use it in GitHub Desktop.
Move in 3D space in Godot using translation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Spatial | |
var speed = 100 | |
func _physics_process(delta): | |
if Input.is_action_pressed("ui_space"): | |
translation += speed * (Vector3.RIGHT.rotated(Vector3(0, 1, 0), rotation.y)) * delta | |
func _input(event: InputEvent) -> void: | |
if event is InputEventMouseMotion: | |
var mouse_pos = get_viewport().get_mouse_position() | |
rotation.y = -(mouse_pos - $Camera.unproject_position(translation)).normalized().angle() |
I learned RIGHT can be replaced with FORWARD BACK UP DOWN and LEFT thank you thank you. Strangely BACK makes the thing go forward.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you.