Third Person Camera View: Locking & snapping back to Look Direction

noisesmattered

New member
Hello!

I'm having a bit of difficulty with Camera Views, and was hoping I could get a bit of help. What I'd like to eventually do is keep all of the default Third Person Adventure view functionality, but modify it so that when the player moves it resets and springs back to the default position. However, even after reading through the documentation and sourcecode I am entirely unclear as to how to approach this.

For a start, in order to properly understand how Camera Views work, I would like to figure out how to lock the Camera View to always face in the direction the player object is facing. I originally believed this meant that I need to override the Move() and Rotate() methods and have them return the LookDirection(), but this simply locks the camera in the start position, rather than locking in relation to the character's movement, so perhaps I'm misunderstanding how I am to use these methods?

Past that, I will then be in need of some way to return the camera to the default position whenever the player moves. To do this, am I correct in assuming that I would use Reset()? Is there an existing method within the Camera View that is called whenever the attached character moves, or would I need to manually track transform position between frames and call it somewhere?

Thank you for your time.
 
For a start, in order to properly understand how Camera Views work, I would like to figure out how to lock the Camera View to always face in the direction the player object is facing. I originally believed this meant that I need to override the Move() and Rotate() methods and have them return the LookDirection(), but this simply locks the camera in the start position, rather than locking in relation to the character's movement, so perhaps I'm misunderstanding how I am to use these methods?
I would start by overriding the rotate method and returning a rotation that looks in the direction of the character. Since you are only worried about the camera right now you do not need to change the LookDirection. For the look direction you can then return m_Transform.forward just to get a base.

Past that, I will then be in need of some way to return the camera to the default position whenever the player moves. To do this, am I correct in assuming that I would use Reset()? Is there an existing method within the Camera View that is called whenever the attached character moves, or would I need to manually track transform position between frames and call it somewhere?
The view types do not overrload reset, but you can subscribe to the OnCharacterMoving event which will change when the character starts or stops moving.
 
Thanks for replying!

So with this code alone:

Code:
    public class MyViewType : ThirdPerson
    {

        public override Quaternion Rotate(float horizontalMovement, float verticalMovement, bool immediateUpdate)
        {
            return m_Transform.rotation;
        }

    }

I produce this result:

<blockquote class="imgur-embed-pub" lang="en" data-id="a/nssMkyT"><a href="//imgur.com/nssMkyT"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>


This does lock the camera's movement at startup, but does not remain aligned to the direction the character is facing as they are moved. What I'd like to do is have the position of the camera update as the player turns, so that it remains behind their head.
 
With that code you are just keeping a static rotation so it'll never change. You'll instead want to return a rotation that is based on the target's direction. The Look At View Type is sort of similar to what you are going for so I recommend taking a look at that View Type.
 
Top