Esempio n. 1
0
func (self *Player) faceMouse(_ components.ComponentHolder, event events.Event) {
	transform := components.GetTransform(self.entity)

	transform.CurrentYaw = math3d.RadToDeg(
		math3d.Atan2(float32(event.MouseYDiff), float32(event.MouseXDiff)),
	)*-1 + 90
}
// Make the entity always look towards the direction of the mouse cursor
// Always rotate around +Y (yaw)
func fixedYMouseMoved(entity components.ComponentHolder, event events.Event) {
	transform := components.GetTransform(entity)

	transform.CurrentYaw = math3d.RadToDeg(
		math3d.Atan2(float32(event.MouseYDiff), float32(event.MouseXDiff)),
	)*-1 + 90
}