The EventSystem is for detecting if the user clicks on any of the Canvas elements. Ignore it but do not remove it
The handle would allow the user to slide the slider value back and forth (Not great for a healthbar!)
maxHealth needs to be public because different characters will have different amount of health, and we need an easy way to set that when the time comes
TakeDamage(2) will subtract 2 from currentHealth
TakeDamage(10) will subtract 10 from currentHealth
Use the following code to get started:
Find the OnCollisionEnter() function:
You may want to temporarily set the rock damage to 10 so the player's health is depleted in 1 hit:
We're going to transition this State out of the Any State node
The Break Animation clip will need an Event which calls ReturnToMovement
We'll set a checkpoint variable when the game starts
This function will need to perform three tasks as written below:
World Space means it exists inside the game world, rather than ontop of the screen.
The blue arrow should be pointing behind the rockSpitter.
It's going to be very large!
Remember we had a:
So the halfExtents would be (0.5, 1, 0.5)
Here we also set the rotation of the box to the player's rotation
We need to get the Health script (if it has one) and tell it to take damage
Kinematic means it is not effected by outside forces.
This gives it time to play its hurt animation before destroying itself.
Build an RPG in Unity
Created 9 months ago
Teach coding to your students with MVCode Teach
MVCode offers an integrated product designed to teach coding to students.
Learn more about MVCode Teach