How to make the player look at an entity

Started by 360Genius on

Topic category: Help with modding (Java Edition)

Last seen on 04:53, 3. Jan 2022
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make the player look at an entity

So here's the thing, I'm trying to make a jumpscare with a custom procedure. I already have the "if collides with player" thing selected, now all I wanna do is make the player look directly at the mob, zoom in (slowness effect) and play a sound. that all seems fairly simple but I CAN'T FIGURE OUT HOW TO MAKE THE PLAYER LOOK AT THE ENTITY'S FACE so any help would be appreciated thanks.

Last seen on 02:51, 19. Feb 2022
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Couldn't you get the…
Sat, 01/01/2022 - 21:33

Couldn't you get the direction that the entity is looking at and then change the player's direction to be the opposite. Assuming that both the entity and the player are in line with one another, if the entity is looking North, then the player would simply have to look South to be facing the entity. 

 

This all depends on how you set up the entity. It'd be more complicated if the player and the mob aren't lined up with one another.

If you want the player to slowly turn towards the entity or such, you may need to get the yaw of the entity then slowly add/subtract the player's yaw (likely in an  "on tick update" trigger) until the player's facing the entity. I think you'd have to set the player's yaw to be negative of the entity's yaw, bit don't quote me on that. I haven't tested any of this yet. Also, you'd want to change the pitch of the player slowly so that the player would be looking in the correct position vertically (that way they aren't staring at the floor or sky)