So I am very new to C# and I’m trying to make a smooth transition from aiming down sights to not aiming them down and vice versa, instead of it just teleporting there. Here’s the code:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using UnityEngine;
public class gunScript : MonoBehaviour
{
bool isMouse2Down;
bool isMouse2Up;
// 0, -0.522, 1.217 ADS Coords
// 0.744, -0.75899, 1.217 default coords
void Start()
{
}
// Update is called once per frame
void Update()
{
isMouse2Down = Input.GetKeyDown(KeyCode.Mouse1);
isMouse2Up = Input.GetKeyUp(KeyCode.Mouse1);
if (isMouse2Down)
{
transform.Translate(-0.744f, 0.23699f, 0f);
}
else if (isMouse2Up)
{
transform.Translate(0.744f, -0.23699f, 0f);
}
}
}