Hero Inland
This is the second scene players encounter in the hero demo. They reach it after leaving the beach through the trunk they find in a cave. It prominently features an entry to the temple scene which is initially blocked by some rocks that can only be removed using a bomb. The bomb equipment item can be found in the canyon scene which is entered through the second trunk located on the right side of the one coming from the beach. Players can also find their second heart shard on a ledge to the left of the trunk. To get it they have to defeat a skeleton that pops out of the ground when anyone gets too close.
Entry
Decides between three different Parameter values.
- Entering from HeroBeach
- Entering from HeroCanyon
- Entering from HeroTemple
Otherwise identical to the entry logic in the beach scene.
Passage
The entry to the temple uses the HeroExitPassageBomb prefab which is a prefab variant of HeroExitPassage with the addition of a bombable cracked wall.
HeroExitPassage behaves pretty much identical to the HeroExitTrunk exits we have already seen. It only differs in the models and timelines used which animate the passage opening and closing with some particles and a sound effect.
The HeroCrackedWall is another destructible similar to the vines we have encountered previously. It can only be destroyed by bombs because HeroBombDamage is set in its Filter field and bombs are the only damage sender with that kind of damage.
When it is destroyed the damage vector is applied as a force to all the rigidbodies in the HeroCrackedWallDestroyed instance. The strength of that force can be changed by adjusting the Magnitude of the damage sender in HeroBombImpact or by changing the PushPower multiplier in the damage receiver of the wall. Of course changing the mass of the rigidbodies will also change how far they are propelled.
Whether the cracked wall has been destroyed is persisted using a DestructionPersister. This kind of persister sets a bool when its gameobject gets destroyed. If it wakes up and that bool is already set it immediately destroys itself. The BehaviourEventTrigger on the same transform activates the Exit whenever the cracked wall is destroyed. This prevents players from unintentionally activating the exit area before actually cracking the wall.
Pots
The pots around the entrance of the temple combine a couple things we have already seen. They can be destroyed by any kind of damage like vines and their destroyed prefab has separate rigidbodies for all the shards resulting in a nice dynamic shattering effect like the cracked wall.
Pots can also be picked up and thrown due to the HeroCarryAction located on the Action transform. It is available as a context action when its area collides with the players CharacterActionArea. The force applied when throwing can be changed in the PowerForward/Up fields. If the PutAllowed field is checked the pot will be softly put down in front of the player when the throw button is pressed while the character is not moving.
It is not used like this in example game scenes but HeroCarryAction could also be used for small plate puzzles. An example of this can be found in the HeroDebuggingGeneral scene(look for CarryObject and PressurePlate).
In addition to regular damage pots are also destroyed when their rigidbody receives a strong enough impulse, usually when they are thrown against something. This is configured in the MaximumImpulse field, how much that impulse affects the destroyed shards can be adjusted in ImpulsePower.
The HeroPotPickupRandom is also a bit more advanced than the pickups we have seen on sea urchins previously. The HeroPotPickup visual script chooses a random pickup from a number of different options. Some of the options, like bombs, are preconditioned by the character already having that item in their inventory. Otherwise players could randomly find bombs in a pot before they actually get them in the canyon scene.
Skeleton
These enemies use a basic GenericCharacter in combination with a NavMeshAgentMovement to move them around. The actions they have available can be found under their Actor. Skeletons are not visible at first because their animator starts them off in the buried animation.
The skeleton stays underground until a character enters the GenericTriggerArea found in the Area object. While the player is inside that area a AnimatorFloat instruction is applied to it as defined in the Instructions field setting the Aggro animator variable to 1. This changes the stance of the hero while locked on and transitions its face to the Mad animation. The HeroCharacter state machine also monitors that variable to change to combat music.
Which actions the skeleton performs is driven by the HeroSkeleton script graph. Once a character enters their area it sets that character as its movement target, starts the Rise action and activates its LockOnPoint. Whenever the current action of its actor changes to null now it checks if it is close enough to punch the player, otherwise it runs towards them. The ScriptMachine also checks for damage. Whenever it receives a hit that does not kill it it force starts the Hit Action making it flinch. If the damage does reduce the health to zero it replaces itself with HeroSkeletonDestroyed. The Ragdoll visual scripting unit transfers all the transform positions to the destroyed model.
The HeroSkeleton script accesses actions by their name. This can be done for any action that is a child of the main actor of the character. This saves us the hassle of keeping all the needed actions as visual scripting variables.