Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6944685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:20:20+00:00 2026-05-27T13:20:20+00:00

i need a non-language specific algorithm for a 3rd person camera. what im having

  • 0

i need a non-language specific algorithm for a 3rd person camera. what im having trouble with is how to keep the camera behind the object and keep the camera’s rotation the same as the objects rotation. any ideas?

Example:

UpdateCamera(camera, target){
    offset = vector(0,height,distance);
    cameraPos = targetPos+offset;
    camAngle = ?????;
}

i know it won’t be that simple but im sure you’ll get the gist of it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:20:21+00:00Added an answer on May 27, 2026 at 1:20 pm

    At its absolute simplest, suppose you have a simple NUV camera class like this:

    /// <summary>
    /// An instance of this class represents a camera for a 3D view.
    /// Cameras are defined with a position and three mutually-orthogonal
    /// axes, namely N (points in the direction faced by the camera),
    /// U (points to the left of the camera) and V (points to the top
    /// of the camera).
    /// </summary>
    sealed class Camera
    {
        //#################### PRIVATE VARIABLES ####################
        #region
    
        private Vector3 m_n;
        private Vector3 m_position;
        private Vector3 m_u;
        private Vector3 m_v;
    
        #endregion
    
        //#################### PROPERTIES ####################
        #region
    
        /// <summary>
        /// The position of the camera.
        /// </summary>
        public Vector3 Position { get { return m_position; } }
    
        /// <summary>
        /// A vector pointing in the direction faced by the camera.
        /// </summary>
        public Vector3 N { get { return m_n; } }
    
        /// <summary>
        /// A vector pointing to the left of the camera.
        /// </summary>
        public Vector3 U { get { return m_u; } }
    
        /// <summary>
        /// A vector pointing to the top of the camera.
        /// </summary>
        public Vector3 V { get { return m_v; } }
    
        #endregion
    
        //#################### CONSTRUCTORS ####################
        #region
    
        /// <summary>
        /// Constructs a new camera.
        /// </summary>
        /// <param name="position">The position of the camera.</param>
        /// <param name="look">A vector pointing in the direction faced by the camera.</param>
        /// <param name="up">The "up" direction for the camera.</param>
        public Camera(Vector3 position, Vector3 look, Vector3 up)
        {
            m_position = position;
    
            m_n = look;
            m_n.Normalize();
    
            m_v = up;
            m_v.Normalize();
    
            m_u = Vector3.Cross(m_v, m_n);
            m_u.Normalize();
        }
    
        #endregion
    
        //#################### PUBLIC METHODS ####################
        #region
    
        /// <summary>
        /// Moves the camera by the specified displacement in the n direction.
        /// </summary>
        /// <param name="delta">The displacement by which to move.</param>
        public void MoveN(float delta)
        {
            m_position += delta * m_n;
        }
    
        /// <summary>
        /// Moves the camera by the specified displacement in the u direction.
        /// </summary>
        /// <param name="delta">The displacement by which to move.</param>
        public void MoveU(float delta)
        {
            m_position += delta * m_u;
        }
    
        /// <summary>
        /// Moves the camera by the specified displacement in the v direction.
        /// </summary>
        /// <param name="delta">The displacement by which to move.</param>
        public void MoveV(float delta)
        {
            m_position += delta * m_v;
        }
    
        /// <summary>
        /// Rotates the camera anticlockwise by the specified angle about the specified axis.
        /// </summary>
        /// <param name="axis">The axis about which to rotate.</param>
        /// <param name="angle">The angle by which to rotate (in radians).</param>
        public void Rotate(Vector3 axis, float angle)
        {
            // Note: We try and optimise things a little by observing that there's no point rotating an axis about itself.
            if(axis != m_n) m_n = MathUtil.RotateAboutAxis(m_n, angle, axis);
            if(axis != m_u) m_u = MathUtil.RotateAboutAxis(m_u, angle, axis);
            if(axis != m_v) m_v = MathUtil.RotateAboutAxis(m_v, angle, axis);
        }
    
        #endregion
    }
    

    Now, each frame:

    1) Get the position pp and direction pdir of the player.
    2) Recreate your camera with position = pp - offset * pdir, look = pdir and up = something sensible (e.g. (0,0,1)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to send a very specific (non-standard) string to an FTP server: dir
I need to call a const function from a non-const object. See example struct
Are there any good ways to define interfaces/class hierarchies in a non language specific
I need to create an iPhone/Mac app that is in a non-English language only.
I'm developing a small tray-icon application for Windows and I need to display non-intrusive
I need to round any non-integers up to the nearest integer, regardless of whether
I need to do a non greedy match and hope someone can help me.
I need to write a non-recursive version of the function sum-squares and Use a
I need to filter alphabetic and non alphanumeric characters from a string to make
I need to save files with non-latin filenames on a filesytem, using PHP. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.