mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +01:00
aim down sights
This commit is contained in:
35
Assets/Scripts/Player/AimDownSights.cs
Normal file
35
Assets/Scripts/Player/AimDownSights.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AimDownSights : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float aimSpeed = 0.01f;
|
||||
[SerializeField][Range(0,1)] float aimVal = 0;
|
||||
[SerializeField] private GameObject gun;
|
||||
[SerializeField] GameObject AimPoint;
|
||||
[SerializeField] GameObject HoldPoint;
|
||||
public bool isAiming = false;
|
||||
bool ADS()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
Debug.Log(Input.GetButton("Aim"));
|
||||
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, aimVal);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Player/AimDownSights.cs.meta
Normal file
11
Assets/Scripts/Player/AimDownSights.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 916f2d37f60a91149bbca3280a1b69ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user