face

fun Location.face(target: Location): Location

Creates a new Location with direction set to face towards a target Location.

This function calculates the direction vector from this Location to the target and returns a new Location with the yaw and pitch set to face that direction.

Example:

val origin = Location(world, 0.0, 64.0, 0.0)
val target = Location(world, 10.0, 64.0, 10.0)
val facing = origin.face(target) // Direction set to face (10, 64, 10)

Return

A new Location with direction set to face the target

Parameters

target

The Location to face towards