Created
September 12, 2018 09:29
-
-
Save 314pies/177987f3ccd5f7f77e25fe178dca2ca2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class wq : MonoBehaviour { | |
public float LastRot; | |
public float Threshold=60.0f; | |
public float Anim, Current; | |
public float yAngle, smooth=0.1f;//targetAbgle | |
private float yVelocity = 0.0F; | |
public Animator s; | |
public Transform a; | |
// Update is called once per frame | |
void Update() | |
{ | |
LastRot = a.localEulerAngles.y; | |
if (LastRot - Current < Threshold && LastRot - Current > -Threshold) | |
Anim = LastRot - Current; | |
else | |
{ | |
Current = LastRot; | |
Anim = 0; | |
} | |
yAngle = Mathf.SmoothDampAngle(transform.localEulerAngles.y, Current, ref yVelocity, smooth); | |
transform.localEulerAngles = new Vector3(0, yAngle, 0); | |
s.SetFloat("HorAimAngle", Anim, 0.1f, Time.deltaTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment