TheOnlyTails
TheOnlyTails

Reputation: 95

How do I rotate a model towards another model in scenform?

I have 6 models - one placed by the player and the rest scattered around it randomly. Currently all the models are "looking" in one direction, but I want the scattered models to be rotated so they "look" at the central model. How do I do it?

(I've tried using Quartenion.axisAngle)

Upvotes: 3

Views: 117

Answers (1)

SGTCheung
SGTCheung

Reputation: 89

Try with Quaternion.lookRotation() like below.

val direction = Vector3.subtract(SCATTERED_MODEL.worldPosition, CENTRAL_NODE.worldPosition)
SCATTERED_MODEL.worldRotation = Quaternion.lookRotation(direction, Vector3.up())

Upvotes: 1

Related Questions