Rotating towards direction without look_at

Godot Version : 4.4

Hello again!

I’m attempting to create a 3D gravity game, but, I’m running into an issue trying to get things to face towards the gravity’s direction. I might wrong, but, look_at(...) doesn’t seem to be usable in this scenario as there isn’t an permanent up direction and was wondering how to get around that if possible. But, if look_at(...) is usable here, I’ll still use it.

gravity_direct =- (global_position - priority_GV.planet_center)

I’m trying to turn gravity_direct into an rotation, also, sorry I’m still quite new to this :')

Hello again indeed :slight_smile:

You can try providing basis.y as an up direction for the look_at(...) function. Basis is a property of 3d nodes that holds orientation and scale information, and y component of it is the current up-vector of the node.

1 Like

You can always set the rotation property.

extends Node3D

@export var GravActorParent : RigidBody3D

func _process(delta: float) -> void:
	look_at(GravActorParent.gravity_direct, GravActorParent.basis.y, true)

I definitely did not get this fully correct as you saw in the video, but, it does the basis of what I was looking for :+1:

Thank you again for the help! : )

I think you have the same issue as before: someone’s grabbing the wrong property or position, but it’s obviously hard to tell from where I’m standing.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.