[text] PohotMode

Viewer

copydownloadembedprintName: PohotMode
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Cinemachine;
  5.  
  6. public class PhotoMode : MonoBehaviour
  7. {
  8.     [SerializeField] PhotoCapture photoCapture;
  9.  
  10.     public CinemachineVirtualCameraBase vcam;
  11.     public CinemachineVirtualCameraBase zoom;
  12.  
  13.     public GameObject projectile;
  14.     public Transform projectileSpawnPoint;
  15.  
  16.     public StarterAssets.ThirdPersonController player;
  17.  
  18.     public float forcehold = 0f;
  19.  
  20.     private bool isPhotoModeOn;
  21.  
  22.  
  23.  
  24.     // Start is called before the first frame update
  25.     void Start()
  26.     {
  27.  
  28.     }
  29.  
  30.     // Update is called once per frame
  31.     void Update()
  32.     {   //0 = left click 1 = right click
  33.         //alt enter
  34.         HandlePhotoModeInput();
  35.  
  36.         HandlePhotoCaptureInput();
  37.     }
  38.  
  39.     private void HandlePhotoCaptureInput()
  40.     {
  41.         if (Input.GetMouseButtonDown(0))
  42.         {
  43.             photoCapture.OnClick(isPhotoModeOn);
  44.             
  45.             UiManager.singleton.ToggleCameraUi(true);
  46.             
  47.         }
  48.     }
  49.  
  50.     private void HandlePhotoModeInput()
  51.     {
  52.         if (Input.GetMouseButtonDown(1)) //right click hold down zooms in
  53.         {
  54.             UiManager.singleton.ToggleCameraUi(true);
  55.             player.SprintSpeed = 1;
  56.             player.MoveSpeed = 1;
  57.             zoom.Priority = 11;
  58.             PhotoModeOn();
  59.             Debug.Log("zoom");
  60.         }
  61.         else if (Input.GetMouseButtonUp(1)) //right click release zooms out
  62.         {
  63.             UiManager.singleton.ToggleCameraUi(false);
  64.             player.SprintSpeed = 5.335f;
  65.             player.MoveSpeed = 2;
  66.             zoom.Priority = 9;
  67.             isPhotoModeOn = false;
  68.         }
  69.     }
  70.  
  71.     private void PhotoModeOn()
  72.     {
  73.         isPhotoModeOn = true;
  74.     }
  75.  
  76.    
  77.     private void FireProjectile()
  78.     {
  79.         GameObject arrow = Instantiate(projectile, projectileSpawnPoint.position, projectileSpawnPoint.rotation);
  80.         arrow.GetComponent<Projectile>().Setforce(forcehold);
  81.         Debug.Log("shot");
  82.         //instanite object
  83.         //bring object back
  84.         //give more power as project is hold down
  85.     }
  86.    
  87. }
  88.  
  89.  

Editor

You can edit this paste and save as new:


File Description
  • PohotMode
  • Paste Code
  • 01 Jul-2022
  • 2.14 Kb
You can Share it: