IEnumerator PickupAnimation(PickupAble PA) { Busy = true; float alpha = 0f; Vector3 StartPos = Current.transform.position; Vector3 StartRot = Current.transform.eulerAngles; Vector3 StartScale = Current.transform.localScale; Current.GetComponent <Collider>().enabled = false; while (alpha < 1f) { Current.transform.position = Vector3.Lerp(StartPos, transform.TransformPoint(this.transform.localPosition + PA.holdPos), alpha); Current.transform.eulerAngles = Vector3.Lerp(StartRot, this.transform.eulerAngles + PA.holdRot, alpha); Current.transform.localScale = Vector3.Lerp(StartScale, new Vector3(PA.holdScale, PA.holdScale, PA.holdScale), alpha); alpha += lerpSpeed; yield return(null); } PC.ItemSpeedMultiplier = PA.HoldSpeedMultiplier; Current.transform.SetParent(this.transform); Current.transform.localPosition = PA.holdPos; Current.transform.localEulerAngles = PA.holdRot; Current.transform.localScale = new Vector3(PA.holdScale, PA.holdScale, PA.holdScale); Busy = false; }
public void ObjectPicked(PickupAble P) { if (!RagdollEnabled && CurrentVehicle == null && EquippedIndex == 0) //can't pickup if dead or in a vehicle { if (CurrentPicked == P) //if picked up is same as in hands { ClearHands(true); //drop it } else if (CurrentPicked == null) //if hands empty { P.GetComponent <SwappableAuthority>().AskForAuthority(); CurrentPicked = P; //fill hands CurrentPicked.Pickup(); An.SetFloat("Arms_Direction", pitch); An.SetInteger("Arms_Index", 1); } else //if different object is picked up when hands full { CurrentPicked.Drop(); //drop old CurrentPicked = P; //assign new CurrentPicked.Pickup(); An.SetFloat("Arms_Direction", pitch); An.SetInteger("Arms_Index", 1); } } }