Forum rules - please read before posting.

Detect Player Facing Camera?

Hi Folks,
I'm trying to extend the cameras so that they retreat in local z by a certain amount when the player turns to face them. I was wondering if there's an existing AC method to detect whether the player is facing a camera.

Thanks!

Comments

  • So, I've got the detection working by checking the angle difference between the _Camera.Target.forward and the mainCamera.ForwardVector().

    I'd like to have this happen whenever the player moves, be it a cursor click, or key input. Is there a generic handler for "onPlayerMove" or the like?

  • There's an OnCharacterSetPath event, but this is only called when pathfinding. Direct player movement (i.e. from key input) is continuous, so there isn't an equivalent for that.

    Best to check for it in an Update loop, as a result. You can check if the Player is currently moving with:

    AC.KickStarter.player.charState = AC.CharState.Move;
    

    Rather than editing / subclassing the GameCamera script directly, you can also likely get by just modifying its zOffset value through another script attached.

  • Thanks, Chris! On that note, I've noticed that the AC GameCameras don't always use the local z for facing direction depth (is intentional,btw?). In this case I assume I'd need to determine the {axis}Offset instead of {z}Offset based on the camera facing direction, correct?

    Thanks again!

  • Yes, it is in world-space.

    You're not restricted to use a GameCamera at all, if you want a custom motion behaviour, though. Attaching the "Basic Camera" component to a regular Unity Camera will make it selectable in AC camera fields/Actions - allowing you to also attach whatever camera motion script you wish to make use of.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.