🦅Fly

1.4.2d

Overview

The Fly State allows the animal to fly and glide. Its State ID is 6.

Creating the Fly State

To create a new Fly State Click the Plus button on the States list

Or just duplicate any of the already created Fly States Assets of any animal you own and drag it to the States List.

Priority

The state should have a higher priority than Idle, Locomotion and Fall. but below Death since the animal can be killed any time.

When the animal is on the this state, all the Lower priorities states are ignored until the exit conditions for this state are fulfilled.

Requirements

Rotator

The State requires an Empty Transform set as a Rotator. This Rotator is the pivot of the Pitch rotation of the animal while flying.

This Rotator Gameobject will be the parent of the RootBone of the Character (First bone of the hierarchy)

Its local Position and Rotation value should be (0,0,0)

Without setting this 'Rotator' gameObject on the Advanced tab the Fly State won't work properly

Up Down Input

To move Up and Down on the Y-Axis the Animator Requires also the Optional parameter: UpDown.

This input is created automatically when the asset is installed.

You can create it manually by clicking on the [Create] Button of the Malbers Input Component.

This will allow the Animal to go Up by pressing [Space], or Down by pressing [C].

Activation

This state mainly uses an Input value to be Activated.

By Input

When Pressing the Input Value for Fly

To create a quick Input for Flying use the Malbers Input context menu:

This will be connected automatically with the state if the state has the same value for its Input.

Using a Zone

A Zone can activate the flying state.

Using a Reaction

Animal Reactions can be used to activate the state. Check Reactions

Exit Conditions

Through code, the exit conditions will be executed to check if the State can exit. In the case of this state, the conditions are:

  • The animal is flying near the ground so he can land (when Can Land is enabled)

  • The Input for fly is released (when the Fly Input is set to pressed)

  • The Input for fly is toggled to off (when the Fly Input is set to toggle)

Common State Tag Properties

These are the General tag option for the Fly state:

  • Main Tag [Fly]

◻️RootMotion

☑️Sprint

◻️Gravity

◻️Grounded

◻️Custom Rotation

◻️Orient To Ground

☑️Ignore Lower States

◻️Persistent = False

◻️Lock Move

◻️Lock Input

☑️+ Root Speed = True

☑️ + Pos Speed

☑️ Free Movement

Limits

You can set all the limits you need for your state.

The limits will block the state from Activating.

Animator

The Fly state requires Animation States that are in charge of the Fly movement.

All states have a core animation state. For fly is a blend tree with the Tag Fly.

Since the State is a moving state, the Speed Multiplier must be set as Parameter "SpeedMultiplier"

This Blend Tree is usually set this way:

If you don't have all the animations, you can fill the missing states with duplicate animations

Tag Modifiers

The Fly State has a “TakeOff” and "Land" tag Modifier by default. This allows the fly state to have an entering and exiting animations before and after entering the core animation, which allows to modify core parameters on the Animal Controller while it is playing any of those animations.

If your character does not have the Take Off or Land Animations this can be ignored.

The values for the Animal parameters that the TakeOff and Land modify are:

Speed Set

The Fly needs a new Speed Set that affects the Fly State. When creating for the first time the Speed Set will be added automatically to the Animal Controller:

If your Fly animations are NOT RootMotion or they don't have the movement and turning speed you desire, then you need to increase the Position and Rotation values to be greater than zero

Fly Parameters

Bank

Banking angle amount used while turning

Pitch Limit:

Limit Angle to Pitch the animal while going up and Down

Pitch Limit = 30 Pitch Limit = 80 (Default)

Bank Strafe

Amount of banking the character can do while strafing and Flying.

Pitch Strafe

Amount of Pitch Rotation the character can do while strafing and Flying.

Max Height

Max Height the character can fly

Inertia Lerp

When Entering the Fly State... The animal will keep the Velocity from the last State if this value is greater than zero

(img)

The take-off parameters will apply a force upwards to the character. This is usually used when the character does not have take-off animations.

Take off Impulse

How much upward force will be applied

Impulse Time

For how long the take-off impulse will be applied

Impulse Curve

Curve value to apply to the TakeOff Impulse

Can Land

If the Animal is close to an object with the Land On Layer, it will automatically Land. (it will exit the Fly State)

Land On Layer

Layer to search for Landing surfaces.

Land Multiplier

Ray Length multiplier to check for ground and automatically land (It uses the Chest Pivot as guide for the Land Ray)

Inertia Lerp

When entering the Fly State... The animal will keep the velocity from the last State for a time if this value is greater than zero.

Avoid Surface

If enabled, It will avoid landing on any object using a surface layer mask. This is used usually for animals that cannot land on Water.

Surface Layer

Layer mask to search for surfaces that the animal cannot land.

Surface Distance

The minimum length, the character will be placed above that surface, to keep it from touching that surface.

Gliding

Flap Speed

Which Speed in the Animation Blend tree will be used to Flap the wings

Glide Speed

Which Speed in the Animation Blend tree will be used to Glide with the wings

Glide Only

The character will activate only the glide animations and it cannot go upwards

Glide Only Idle S

When the Forward Input is Released, this will be the movement speed the gliding will have

Glide Only Idle V

When the Forward Input is Pressed, this will be the movement speed the gliding will have

Auto Glide

If Enabled the animal will change from flapping to gliding automatically

Glide Chance

Time range the animal will glide when Auto Glide is true

Flap Chance

Time range the animal will flap the wings when Auto Glide is true

Variation

Variation to make Random Flap and Glide Animation

Down Acceleration

Gravity Force applied to the Fly State.

Gravity Drag

If the value is greater than zero the character will go down gradually while flying.

Down Acceleration

If the character plunges down toward the ground it will gain speed depending on the value of this parameter.

Bone Block Landing

Sometimes when the animal is very large and has a large head the landing may be blocked by the head and it cannot properly land. that is why, when Can Land is active, a second ray is cast from another bone (Head) to see if we can find ground to land.

Bone Name

Name of the Bone. By default is "Head"

Bone Offset Position

Local Offset position from the bone position

Block Land Distance

Ray Distance for finding the ground from the Bone

Last updated