using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Scope : MonoBehaviour
{
public Animation scope;
public GameObject go;
// Use this for initialization
void Start()
{
scope = gameObject.GetComponent<Animation>();
go.SetActive(false);
}
// Update is called once per frame
void Update()
{
foreach (AnimationState state in scope)
{
if (Input.GetMouseButtonDown(1))
{
state.speed = 2;
scope.Play();
}
if (Input.GetMouseButtonUp(1))
{
state.speed = -2;
}
if (Input.GetMouseButtonUp(1) && state.time == 0f)
{
state.speed = -2;
state.time = 0.49f;
scope.Play();
}
if (Input.GetMouseButton(1) && state.time == 0f)
{
go.SetActive(true);
}
else
{
go.SetActive(false);
}
}
}
}