GroundCollisionDetection

From Resonite Wiki

In order to detect when a character is on the ground to drive some action further down the line here is how you can do this in two different ways.

We are going to take the example of driving a Shape Key change, in this case, this shape key controls the wings of the avatar. When the avatar is on the ground, the wings will retract, when it is flying (or jumping) they will expand.

ProtoFlux Based

To do this in ProtoFlux we need to extract the Source Node for the CurrentOnGround value in the VRIKAvatar component situated at the Root of the avatar.

In this monster of a component, find the CurrentOnGround value (Under Gaits (list) and above Body Nodes). This value is True if the feet collide with a ground object, and false if they don't. Then we need to convert this bool to a float between 0-1, we can use the 0/1 Node.

We also want to smooth this transition so that the shape key goes smoothly from 0 to 1, so we use a Value Smooth Lerp<float> Node, and we plug in a speed. Finally, we plug this value onto the Shape Key's Value Field Drive<float> Node which we extract from the object we need to drive.

The final setup will look like this:

ProtoFlux Nodes for the ground collision detection driving a shape key

Component based

But we don't need any ProtoFlux to do this, and we can instead use Components. First create a new empty object (or place them in an object inside your character) and parent this empty object under your character (you can also reset it's transform so that it's centered with your character and isn't flying around.

Then we will need three components: ValueCopy<bool> so that we can copy the state of CurrentOnGround to the next component BooleanValueDriver<float> which we use to convert the bool to a float between 0 and 1 SmoothValue<float> which takes the converted float and outputs the smooth lerp onto the shape key.

The base setup looks like this.

Initial state of component based for the ground collision detection driving a shape key

Then you need to plug the different elements in as follows:

Explainer of component based for the ground collision detection driving a shape key

And it should look something like this at the end:

Final state of component based for the ground collision detection driving a shape key