mNo edit summary |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
[[Category: | [[Category:Tutorial]] | ||
[[Category: | [[Category:Tutorial:Avatar]] | ||
In order to detect when a character is on the ground to [[driving|drive]] some action further down the line here is how you can do this in two different ways. | In order to detect when a character is on the ground to [[driving|drive]] some action further down the line here is how you can do this in two different ways. | ||
Line 8: | Line 8: | ||
To do this in ProtoFlux we need to extract the Source Node for the CurrentOnGround value in the [[VRIKAvatar (Component)|VRIKAvatar]] component situated at the Root of the [[avatar]]. | To do this in ProtoFlux we need to extract the Source Node for the CurrentOnGround value in the [[VRIKAvatar (Component)|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 [[ | 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 [[Type:Bool|bool]] to a [[Type:Float|float]] between 0-1, we can use the [[Zero One (ProtoFlux)|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 (ProtoFlux)|Value Smooth Lerp<float>]] Node, and we plug in a speed. Finally, we plug this value onto the Shape Key's [[Value Field Drive (ProtoFlux)|Value Field Drive<float>]] Node which we extract from the object we need to drive. | 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 (ProtoFlux)|Value Smooth Lerp<float>]] Node, and we plug in a speed. Finally, we plug this value onto the Shape Key's [[Value Field Drive (ProtoFlux)|Value Field Drive<float>]] Node which we extract from the object we need to drive. | ||
Line 19: | Line 19: | ||
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. | 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 (Component)|ValueCopy<bool>]] so that we can copy the state of ''CurrentOnGround'' to the next component [[BooleanValueDriver (Component)|BooleanValueDriver<float>]] which we use to convert the [[ | Then we will need three components: [[ValueCopy (Component)|ValueCopy<bool>]] so that we can copy the state of ''CurrentOnGround'' to the next component [[BooleanValueDriver (Component)|BooleanValueDriver<float>]] which we use to convert the [[Type:Bool|bool]] to a [[Types:Float|float]] between 0 and 1 [[SmoothValue(Component)|SmoothValue<float>]] which takes the converted [[Types:Float|float]] and outputs the smooth lerp onto the shape key. | ||
The base setup looks like this. | The base setup looks like this. |
Latest revision as of 01:13, 1 June 2024
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:
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.
Then you need to plug the different elements in as follows:
And it should look something like this at the end: