Forum rules - please read before posting.

Third Person Camera zoom with COMBAT EXAMPLE

I am using COMBAT EXAMPLE to create a resident evil style combat and inventory system, but since I use the third person camera I would like that when I aim the weapon the camera near the player is zoomed, is it possible to do something like this?

Comments

  • edited December 2021

    I'd say it'd be a case of switching to a separate camera that's got its own set of distance/FOV etc values whenever aiming, and switching back to the "regular" camera otherwise.

    The package's PlayerCombat script has an "IsAiming()" function that you can read in a custom script to set the correct camera. Something like this:

    using UnityEngine;
    using AC;
    using AC.CombatExample;
    
    public class AimCamera : MonoBehaviour
    {
    
        public _Camera normalCamera;
        public _Camera aimCamera;
        public PlayerCombat playerCombat;
        public float transitionTime = 1f;
    
        void Update ()
        {
            if (!KickStarter.stateHandler.IsInGameplay ())
            {
                return;
            }
    
            if (playerCombat.IsAiming ())
            {
                if (KickStarter.mainCamera.attachedCamera == normalCamera)
                {
                    KickStarter.mainCamera.SetGameCamera (aimCamera, transitionTime);
                }
            }
            else
            {   
                if (KickStarter.mainCamera.attachedCamera == aimCamera)
                {
                    KickStarter.mainCamera.SetGameCamera (normalCamera, transitionTime);
                }
            }
        }
    
    }
    

    Paste into a C# script named AimCamera and attach to your Player, then fill in its Inspector.

    To reiterate the package's Readme, though: this example is meant to demonstrate the use of custom scripting to extend gameplay. You will need to rely on custom scripting to make a proper combat game with AC.

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.