SHARE
TWEET

Untitled

a guest Feb 26th, 2020 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Animations;
  5.  
  6. public class CameraSwitcher : MonoBehaviour
  7. {
  8.  
  9.     private PositionConstraint PosiCon;
  10.     public ConstraintSource player;
  11.     public ConstraintSource companion1;
  12.     public ConstraintSource companion2;
  13.     public ConstraintSource companion3;
  14.     AIClickToMove aiClickMove;
  15.  
  16.     public Transform playerCamTarget, comp1CamTarget, comp2CamTarget, comp3CamTarget;
  17.  
  18.  
  19.     // Start is called before the first frame update
  20.     void Start()
  21.     {
  22.         playerCamTarget = GameObject.Find("PlayerCameraTarget").transform;
  23.         comp1CamTarget = GameObject.Find("Companion1CameraTarget").transform;
  24.         comp2CamTarget = GameObject.Find("Companion2CameraTarget").transform;
  25.         comp3CamTarget = GameObject.Find("Companion3CameraTarget").transform;
  26.  
  27.         PosiCon = this.GetComponent<PositionConstraint>();
  28.  
  29.         player.sourceTransform = playerCamTarget;
  30.         companion1.sourceTransform = comp1CamTarget;
  31.         companion2.sourceTransform = comp2CamTarget;
  32.         companion3.sourceTransform = comp3CamTarget;
  33.  
  34.         player.weight = 1;
  35.  
  36.         PosiCon.AddSource(player);
  37.         PosiCon.AddSource(companion1);
  38.         PosiCon.AddSource(companion2);
  39.         PosiCon.AddSource(companion3);
  40.  
  41.         PosiCon.SetSource(0, player);
  42.         PosiCon.SetSource(1, companion1);
  43.         PosiCon.SetSource(2, companion2);
  44.         PosiCon.SetSource(3, companion3);
  45.  
  46.         player = PosiCon.GetSource(0);
  47.         companion1 = PosiCon.GetSource(1);
  48.         companion2 = PosiCon.GetSource(2);
  49.         companion3 = PosiCon.GetSource(3);
  50.     }
  51.  
  52.     public void SwitchCompanion1()
  53.     {
  54.         /*var PosiCon = GameObject.Find("TARGET").GetComponent<PositionConstraint>();
  55.         comp1CamTarget = GameObject.Find("Companion1CameraTarget").transform;
  56.         companion1.sourceTransform = comp1CamTarget;
  57.         Cleaner();
  58.         PosiCon.AddSource(companion1);
  59.         companion1.weight = 1;
  60.         PosiCon.SetSource(0, companion1);*/
  61.         player.weight = 0;
  62.         PosiCon.SetSource(0, player);
  63.         companion1.weight = 1;
  64.         PosiCon.SetSource(1, companion1);
  65.         companion2.weight = 0;
  66.         PosiCon.SetSource(2, companion2);
  67.         companion3.weight = 0;
  68.         PosiCon.SetSource(3, companion3);
  69.  
  70.     }
  71.     public void SwitchPlayer()
  72.     {
  73.         player.weight = 1;
  74.         PosiCon.SetSource(0, player);
  75.         companion1.weight = 0;
  76.         PosiCon.SetSource(1, companion1);
  77.         companion2.weight = 0;
  78.         PosiCon.SetSource(2, companion2);
  79.         companion3.weight = 0;
  80.         PosiCon.SetSource(3, companion3);
  81.     }
  82.     public void SwitchCompanion2()
  83.     {
  84.         player.weight = 0;
  85.         PosiCon.SetSource(0, player);
  86.         companion1.weight = 0;
  87.         PosiCon.SetSource(1, companion1);
  88.         companion2.weight = 2;
  89.         PosiCon.SetSource(2, companion2);
  90.         companion3.weight = 0;
  91.         PosiCon.SetSource(3, companion3);
  92.     }
  93.     public void SwitchCompanion3()
  94.     {
  95.         player.weight = 0;
  96.         PosiCon.SetSource(0, player);
  97.         companion1.weight = 0;
  98.         PosiCon.SetSource(1, companion1);
  99.         companion2.weight = 0;
  100.         PosiCon.SetSource(2, companion2);
  101.         companion3.weight = 1;
  102.         PosiCon.SetSource(3, companion3);
  103.     }
  104.  
  105.     public void Cleaner()
  106.     {
  107.         var PosiCon = GameObject.Find("TARGET").GetComponent<PositionConstraint>();
  108.         PosiCon.RemoveSource(0);
  109.     }
  110. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top