- Home /
Question by
Michael_R · Jul 15, 2019 at 07:10 PM ·
c#animationscripting problem
Why does my recoil Anim sucks (C#)?
Hello,
i am trying to do a recoil like in Pubg:
https://youtu.be/duEWp_6v8_4?t=9
my recoil:
where the recoil is at first very strong but then pretty much sticks to one position and shakes. So i want it a bit more shaky and less lerpy (authentic) hehe
void Update()
{
if (Input.GetMouseButton(0) && playerhands.RifleHands.AmmoCurrent>0)
{
RandRec = Random.Range(-1f, 1f);
sumrecoil.z *= RandRec; //Just random Shaking
recoilRot.y *= RandRec;
sumrecoil.x= Mathf.Clamp(sumrecoil.x, -recoilweight * recoilDir.x, recoilweight * recoilDir.x); //trying to clamp it so the sumrecoil isnt alway higher/lower than the recoil*(-)2
sumrecoil.z=Mathf.Clamp(sumrecoil.z, -recoilweight * recoilDir.z, recoilweight * recoilDir.z);
recoil();
}
weapon.transform.localPosition = Vector3.Lerp(weapon.transform.localPosition, adsPointdefault, Time.deltaTime * 5.0f); //go back to default Aiming Position
weapon.transform.localRotation = Quaternion.Slerp(weapon.transform.localRotation, adsPointdefaultRotation, Time.deltaTime * 5.0f); //
}
Thanks for help ;)
Comment
Your answer
Follow this Question
Related Questions
My Animation Loops 3/4 of the way through 3 Answers
Flip between 2 states constantly C#? 1 Answer