Question by 
               Complexium · May 23, 2018 at 12:00 AM · 
                camerascripting problemvariabletargetcenter  
              
 
              Centering camera between my player and a selected object.
Hi!
I have a camera with 2 target slot. In the first slot, I place my player and the second slot is for the selected object. So for exemple, if I click a door, the camera will move and center itself between the door and the player. And then when I click away from the door, the second slot should return to null and recenter the camera on the player alone.
How should I go about this? right now I can only make it work by placing the player and the door object in the slots manually. how do I make it change when I click a door or any other object in the game?
Thanks for your help!
here is the code I have for the moment on my camera ojb.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CameraFollow : MonoBehaviour {
     
     public Transform target;
     public Transform targetSelection;
     public Vector3 center;
     public float m_speed = 0.1f;
     Camera mycam;
 
     void Start () {
         mycam = GetComponent<Camera> ();
     }
     
     void Update () {
 
         mycam.orthographicSize = (Screen.height / 100f) / 6f;
 
         center = ((target.position + targetSelection.position) / 2.0f);
 
         if (target & targetSelection) 
         {
             transform.position = Vector3.Lerp (transform.position, center, m_speed) + new Vector3 (0.0f, 0.35f, 0.05f);
         } 
     }
 }
 
              
               Comment
              
 
               
              Your answer