Search Unity

Can we use ThirdPersonCamera without ThirdPersonController? [SOLVED]

Discussion in 'Animation' started by WikiMalik, May 25, 2015.

  1. WikiMalik

    WikiMalik

    Joined:
    Nov 13, 2014
    Posts:
    16
    I've removed ThirdPersonController from my character and instead added a NavMeshAgent as a controller. But Now the ThirdPersonCamera is glitching. Only works if enable TPC.

    The Idea is to use NMA's collision properties to avoid intersecting NPCs, but I've this hurdle in my path. Three hours searching for the solution & nothing. Help Please!

    Edit : I just opened the script, and on line#57 says
    Debug.Log("Please assign a target to the camera that has a ThirdPersonController script attached.");

    Now I desperately need an alternative.
     
    Last edited: May 25, 2015
  2. WikiMalik

    WikiMalik

    Joined:
    Nov 13, 2014
    Posts:
    16
    Alright, I figured out the solution. It is real easy if you just keep some variables in track.

    1) Open ThirdPersonCamera Script
    2) Find 'Controller' in the script & remove associated lines of code, except the lines bold lines. You should get 7 results in the default TPC script.


    private var controller : ThirdPersonController;

    if (_target)
    {
    controller = _target.GetComponent(ThirdPersonController);
    }

    if (controller)
    {
    var characterController : CharacterController = _target.GetComponent.<Collider>();
    centerOffset = characterController.bounds.center - _target.position;
    headOffset = centerOffset;
    headOffset.y = characterController.bounds.max.y - _target.position.y;
    }
    else
    Debug.Log("Please assign a target to the camera that has a ThirdPersonController script attached.");

    if (!controller)
    return;

    3) the replace the bold variables in these lines without your own values. If you have already set up the character and want the camera to be at exact position. Debug.Log these variables (Like print("headOffset = "+ headOffset+" || characterController.bounds.max.y = "+ characterController.bounds.max.y ) and later replace the variables with absolute values.


    characterController.bounds.center (Vector3)
    headOffset (float)
    characterController.bounds.max.y (float)
    controller.GetLockCameraTimer () (float)

    controller.IsMovingBackwards () (boolean)
    The last two variables can be referenced to your custom script for interactivity. If you have trouble resolving it do contact me.

    I Hope this Helps someone around here.







     
    theANMATOR2b likes this.