In unity, using animation rigging, i want my head to move when shooting. What do you…
- User
In unity, using animation rigging, i want my head to move when shooting. What do you suggest to do and what component are involved to make such a thing?
- Assistant
- User
public IEnumerator CharacterDeath() { float timeElapsed = 1f; float lerpDuration = 14;
float startValue = 0; float endValue = 1.6f; if (isDead) { //PLAY AUDIO audioSource.PlayOneShot(DeathSound); audioSource.PlayOneShot(DeathTragicMusic); //DISABLING CAM&INPUT camRig.enabled = false; camRig._IsCollisionsEnabled = false; InputSource.IsEnabled = false; fLook.enabled = false; if (_1stPerson) { camRig.ActivateMotor(6); } //DEATH ANIMATION motionController.SetAnimatorMotionPhase(0, 3375, true); Player.tag = "Dead"; m_Animator.SetBool("isDead", true); //DISABLING UI LightSource.enabled = false; QuestUI.SetActive(false); ShotgunUI.SetActive(false); GasolineUI.SetActive(false); PlayerVitalsUI.SetActive(false); Inventory.SetActive(false); KnifeUI.SetActive(false); //STOP BLOOD m_Animator.SetBool("isInjured", false); BloodScreenFx.SetBool("50Health", false); BloodScreenFx.SetBool("100Health", true); //SEND ZOMBIES ANIMATION zombies = GameObject.FindGameObjectsWithTag("Enemy"); closestZombie = null; foreach (GameObject zombie in zombies) { float curDistance; curDistance = Vector3.Distance(transform.position, zombie.transform.position); zombieHealth = zombie.gameObject.transform.GetComponent<DemoEnemyControls>(); crawlerControls = zombie.gameObject.transform.GetComponent<CrawlerControls>(); if (curDistance < 1f) { if (zombieHealth != null) { zombieHealth.EatPlayer(); zombieHealth.transform.LookAt(transform); transform.LookAt(zombieHealth.transform); } if (crawlerControls != null) { crawlerControls.EatPlayer(); crawlerControls.transform.LookAt(transform); transform.LookAt(crawlerControls.transform); } } } yield return closestZombie; //NEW BLOOD FX while (timeElapsed < lerpDuration) { camBlood.Blood_On_Screen = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration); timeElapsed += Time.deltaTime; yield return null; } camBlood.Blood_On_Screen = endValue; //ENABLING GAMEOVER UI + DEATH MUSIC Gameover.SetActive(true); Cursor.visible = true; audioSource.clip = GameOverUIMusic; audioSource.Play(); audioSource.loop = true; deathCount++; if (HeartbeatAudioSource.isPlaying) { HeartbeatAudioSource.Stop(); } } } - Assistant
- User
Write an optimised version of this function
- Assistant
- User
In unity, how do I make the character to react to the enemy hit. Enemies are zombies, and i want to character to react to them when he's being bitten by one of them. Like a short sequence of animation between the player and the zombie, making the scene more realistic.
- Assistant