Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class barrelLerp : MonoBehaviour
- {
- Vector3 startPos;
- public Transform endPos;
- public float t;
- public AnimationCurve barrelAnim;
- public bool shot;
- void Start()
- {
- shot = false;
- }
- void Update()
- {
- startPos = transform.position;
- if (Input.GetMouseButtonDown(0) && !shot)
- {
- shot = true;
- }
- if(shot)
- {
- t += Time.deltaTime;
- if (t>=1)
- {
- t = 0;
- shot = false;
- }
- LerpMovement();
- }
- }
- void LerpMovement()
- {
- transform.position = Vector3.Lerp(startPos, endPos.position,barrelAnim.Evaluate(t));
- print("Animazione completata");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement