Skip to content

Instantly share code, notes, and snippets.

@314pies
Created September 12, 2018 09:29
Show Gist options
  • Save 314pies/177987f3ccd5f7f77e25fe178dca2ca2 to your computer and use it in GitHub Desktop.
Save 314pies/177987f3ccd5f7f77e25fe178dca2ca2 to your computer and use it in GitHub Desktop.
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