GODOT 4.4
hi everyone!
I face a very annoying problem with GODOT. I’m doing a 3D project for mobile and the desired configuration was that, if the player pressed on the scene (except objects), he would walk forward in the direction he was (in the horizontal plane).
In my case, the horizontal rotation is marked by Y, and the vertical ones are X and Z; and in the position, the horizontal ones are Z and X, and the vertical one is Y.
In my game, the character starts looking in the direction of -X, her right is -Z and her left is +Z, behind her is X.
My character is composed not of a 3D model, but of a characterbody3d (which I only made so Godot would let me create the character, I don’t use it for absolutely anything), inside it, there is a Colision3d (in the shape of the character which is a vertical parallelepiped), A 3d node as a parent of the 3d camera. The character doesn’t have a model, because I wanted to make her like that.
I created a group containing the collision, the node and the camera, called elisa. One important thing to note is that the camera is the only one that starts with a rotation of -90y.
To make the movement, I made a signal in the root node
func _on_room_1_input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) → void:
if event is InputEventScreenTouch:
get_tree().call_group(“elisa”, “mover”)
room_1 is the cenary.
And in the group nodes I put SEVERAL variations of chances to make them move normally, like a character and not go to the fourth dimension .
I tried:
func mover(direction):
translate(direction * 0.1)
func mover():
var direcao = -transform.basis.z
direcao.y = 0
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var direcao = transform.basis.z # Sem o menos
direcao.y = 0
if direcao.length() > 0.001:
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var direcao = transform.basis.z # Troca o - por nada aqui
direcao.y = 0
if direcao.length() > 0.001:
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var direcao = -transform.basis.z
direcao.y = 0
if direcao.length() > 0.001:
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var direcao = transform.basis.z # Tenta com isso pra “frente”
direcao.y = 0
if direcao.length() > 0.001:
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var direcao = transform.basis.x # Direção +X com rotação em Y
direcao.y = 0
if direcao.length() > 0.001:
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var direcao = -transform.basis.z
direcao.y = 0
print(direcao) # Ver a direção calculada
if direcao.length() > 0.001:
direcao = direcao.normalized()
translate(direcao * 0.1)
func mover():
var Direction= rotation.y
if rad_to_deg(Direction) - 90 > -90 and rad_to_deg(Direction) - 90 < 0: position.x += -10.0
if rad_to_deg(Direction) - 90 > -180 and rad_to_deg(Direction) - 90 < -90: position.z += -10.0
if rad_to_deg(Direction) - 90 > -270 and rad_to_deg(Direction) - 90 < -180: position.x += 10.0
if rad_to_deg(Direction) - 90 > -270 and rad_to_deg(Direction) - 90 < 0: position.z += -10.0
func mover():
# Movimento na direção “frente” relativa à rotação em Y
var direcao = Vector3(cos(rotation.y), 0, -sin(rotation.y))
# Move o Node3D pai (e assim todos os filhos como CollisionShape e Camera)
translate(direcao * 0.1)
I tried this all, and nothing worked right