Godot Version
4.5.1
Question
I thought was at a good start when I was able to rotate mesh and other things, however, I realize I was only able to rotate once instead of rotating infinitely while holding down the joystick. I have tried my best but was not able to figure it out. This is the closest I got with out runtime.
extends Node3D
var speed = 4
func _process(_delta: float) -> void:
var joy_dir = Input.get_vector("pan_down", "pan_up", "rotate_left", "rotate_right")
Basis(Vector3(joy_dir.x, 0, joy_dir.y) * _delta * speed)
This doesn’t change rotation, you probably get a warning along the lines of “This statement has no effect.” You need to add rotation to your rotation property, usually one does this on different axis for different nodes to help prevent strange rotations
func _process(delta: float) -> void:
var joy_dir = Input.get_vector("pan_down", "pan_up", "rotate_left", "rotate_right")
rotation.y += joy_dir.x * delta * speed # left/right rotation
$Camera.rotation.x += joy_dir.y * delta * speed # tilt up/down rotation
can joy_dir be put inside of a function instead of having to break it down into two separate line like rotated()?
You can put any code inside a function. It’s up to you how many functions you want to divide your code into.
1 Like
thank you for helping me, I will ask more question in future.
1 Like