Cool hurt animation
Hi there,
Is there an easy way to make the first person camera tilt side to side when the player takes damage?
Thanks :D
Answer by eses · Sep 11, 2018 at 10:17 AM
Hi, @Lord_meow_Sambo
...your question is actually how to play animation from code.
Pseudo code:
Create an animation clip for some object that is your placeholder for your player head.
Create a method to some MonoBehaviour script you have.
If you are using the "new" or non-legacy animation system, in this method, trigger animation from your animator (hurt animation).
Call this method when you get hurt (use string name that matches trigger name in your animation graph):
myAnimator.SetTrigger("hurt");
See:
https://docs.unity3d.com/ScriptReference/Animator.SetTrigger.html
@Lord_meow_Sambo - Use comment when commenting....
I told that create an animation for your head placeholder. You can stack as many transforms, if you need to have separation of different animations and transformations.
Your answer
Follow this Question
Related Questions
Unity 2D - Making a hitbox damage a for just once. 1 Answer
Problems with health system based on hearts 1 Answer
Tool Durability if Hit any Collider 1 Answer
Apply Damage Universally 0 Answers