mirror of
				https://github.com/DerTyp7/defrain-shooter-unity.git
				synced 2025-10-31 13:37:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			884 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			884 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| 
 | |
| public class AimDownSights : MonoBehaviour
 | |
| {
 | |
|     [SerializeField] float aimSpeed = 0.01f;
 | |
|     [SerializeField][Range(0,1)] public  float aimVal = 0;
 | |
|     [SerializeField] private GameObject gun;
 | |
|     [SerializeField] GameObject AimPoint;
 | |
|     [SerializeField] GameObject HoldPoint;
 | |
|     public bool isAiming = false;
 | |
|     bool ADS() 
 | |
|     {
 | |
|         
 | |
|         return true;
 | |
|     }
 | |
|     private void FixedUpdate()
 | |
|     {
 | |
|         if (Input.GetButton("Aim")) 
 | |
|         {
 | |
|             isAiming = true;
 | |
|             aimVal += aimSpeed;
 | |
|         } 
 | |
|         else 
 | |
|         {
 | |
|             isAiming = false;
 | |
|             aimVal -= aimSpeed;
 | |
|         }
 | |
|         aimVal = Mathf.Clamp(aimVal,0,1);
 | |
| 
 | |
|         gun.transform.position = Vector3.Lerp(HoldPoint.transform.position, AimPoint.transform.position,Mathf.Pow(aimVal,1.3f)) ;
 | |
|     }
 | |
| }
 | 
