static Rotation LookAt( Vector3 forward, Vector3 up )

Summary

Create a Rotation (quaternion) from a forward and up vector

static Rotation LookAt( Vector3 forward )

Summary

Create a Rotation (quaternion) from a forward vector, using Vector3.Up as an up vector. This won't give nice results if ['paramref'] is very close to straight up or down, if that can happen you should use Rotation.LookAt.
trophy 25
Jul 2024 10 posts
Simple component which makes the object always face towards the scene's camera:
public sealed class FaceTowardsCamera : Component
{
	protected override void OnUpdate()
	{
		WorldRotation = Rotation.LookAt( WorldPosition - Scene.Camera.WorldPosition );
	}
}
trophy 555
May 2021 15 posts
oooor you can use the static method meant for this! https://sbox.game/api/Rotation/FromToRotation
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.