Adding Flight to an Avatar: Difference between revisions

From VR Wiki
Avatar 3.0
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:


{{Warning|This entire feature relies on a physics bug, which may be fixed in the future.}}
{{Warning|This entire feature relies on a physics bug, which may be fixed in the future.}}
{{Note|This guide was written in Unity 2018.4.20f1 on Windows 10. YMMV.}}
__TOC__
== VRC SDK 3 Methods ==
=== Inclined Plane Method ===
Same method, but with a few tweaks. Tested by [[User:N3X15|N3X15]] ([[User talk:N3X15|talk]]) 18:57, 16 November 2020 (CST)


{{Note|This guide was written in Unity 2018.4.20f1 on Windows 10. YMMV.}}
# Right-click on your avatar's root node in the scene hierarchy.
# Select '''Create Empty''' from the context menu.
# Rename the new GameObject to ''Fly'' or something memorable.
# Right-click Fly in the scene hierarchy.
# Choose '''3D Object > Cube'''.[[File:Unity 2020-11-02 20-20-40.png|thumb|What your scene hierarchy should look like.]]You should now see a Cube under the Fly object.
# Select Cube.
# In the Inspector tab, set the following:
#* Rotation:
#** X: -15
#** Y: 0
#** Z: 0
#* Scale:
#** X: 2
#** Y: 0.4,
#** Z: 5
# Select the [[File:Unity Editor - Popup.png]] icon on the far right of the ''Mesh Renderer'' component.
# Choose '''Remove Component'''.
# Make sure ''Box Collider'' is still checked (enabled).
[[File:Unity 2020-11-03 04-07-07.png|How everything should look.|alt=|center|frame]]
Now you just need to make a toggle for ''Fly''.
 
==== Toggles ====
 
# Create an animation to enable the ''Fly'' object, called ''Fly On''.
## Duplicate the avatar in your scene. Name doesn't matter, you can leave it as default.
## Open your Animation tab. ('''Window > Animation > Animation''')
##'''Make absolutely certain you have selected the DUPLICATE avatar in your scene.'''
## In your animation tab, click the Create button.
## Save the animation somewhere convenient, and name it ''Fly On.anim''.
## Click '''Add Property'''.
## Click the + icon next to '''Fly > Is Active'''.
## Click the keyframe diamond at the end of the timeline.
## Press delete.
## Click the keyframe diamond at the beginning of the keyframe.
## Check the checkbox next to ''Fly: Game Object.Is Active'' to make it active for that keyframe.
## Click on the frame line immediately after the 0:00 mark.
## Add a new keyframe using the [[File:Unity Editor - Animation.AddKeyframe.png|alt=Add Keyframe]] '''Add Keyframe''' button.
## Make sure that ''Fly: Game Object.Is Active'' is still checked.
# Add an animation to disable the ''Fly'' object, called Fly Off.
## Perform the same steps as above, but name it ''Fly Off'', and uncheck the ''Fly: Game Object.Is Active'' checkbox.
# Delete the duplicate avatar.
# Make an expression menu object for your avatar.
## Right-click your avatar's assets directory in the Project View.
## Create > Folder named Menus.
## Right-click the new folder.
## Create > VRChat > Avatars > Expressions Menu.
## Name it ''Avatar Root Menu.''
## Select the avatar's root node in your Scene Hierarchy.
## Under your VRC Avatar Descriptor, expand the Expressions section.
## Drag ''Avatar Root Menu'' into the Menu slot.
# Make a parameters object for your avatar.
## Right-click your avatar's assets directory in the Project View.
## Create > Folder named Parameters.
## Right-click the new folder.
## Create > VRChat > Avatars > Expression Parameters.
## Name it Avatar Params
## Select the avatar's root node in your Scene Hierarchy.
## Under your VRC Avatar Descriptor, expand the Expressions section.
## Drag Avatar Params into the Parameters slot.
## In an empty slot, add an Int called ''Flying''.
# Add a new toggle control to your menu.
## Click on the new menu in your assets.
## Ensure the Active Avatar is
## Click '''Add Control'''.
## Set the '''Name''' to ''Flying''.
## Leave '''Icon''' as None.
## Set '''Type''' to Toggle.
## For '''Parameter''', select ''Flying, Int'' from the dropdown.
## Set '''Value''' to <code>1</code>.
# Make an FX Animator.
## Right-click your avatar's assets directory in the Project View.
## Create > Folder named Animators.
## Right-click the new folder.
## Create > Animator Controller.
## Name it Avatar FX.
## Select the avatar's root node in your Scene Hierarchy.
## Under your VRC Avatar Descriptor, expand the Playable Layers section.
## Click the Default FX button to override it.
## Drag the new Avatar FX animator into the FX slot.
# Open your FX animator by double-clicking on it.
# At the very top, select the '''Parameters''' tab.
# Click the [[File:Unity Editor - Toolbar Plus More.png]] button.
# Select '''Int'''.
# Type in <code>Flying</code> (case-sensitive).
# Leave the default value as 0.
# Go back to the '''Layers''' tab.
# Create a new layer using the + button.
# Double-click on the layer's name.
# Name it <code>Flying</code>.
# Click the white [[File:Unity Editor - SettingsIcon.png|alt=Gear icon]] on the far right of the new layer's name.
## Set '''Weight''' to 1.
## Leave '''Mask''' set to None.
## Ensure '''Blending''' is Override.
# Select the layer by clicking on it.
# Drag Fly Off into the graph. It's highlighted in orange, so this is our landing state, where the animation controller will sit by default.
# Drag Fly On into the graph.
# Right-click the Fly Off node in the graph.
# Select Make Transition.
# Click Fly On to finish making the transition from Fly Off to Fly On.
# Click the new Fly Off -> Fly On transition.
## Uncheck '''Has Exit Time'''.
##* You will get a warning, ignore it.  We're fixing it in the next step.
## Click the + button under Conditions.
## Select '''Flying''' from the first dropdown.
## Select '''Equals''' from the second dropdown.
## Enter <code>1</code> in the textbox.
# Create another transition between Fly On and Exit.
## Uncheck Has Exit Time.
## Add a condition.
## Select Flying from the first dropdown.
## Select Not Equals from the second.
## Enter <code>1</code> in the textbox.
 
==== Usage ====
 
# Enable the Fly object.
# Move forward and jump, or fall off of something.
# Move forward to go up.
# Move backwards to go down.
# Strafe to stay at the same level.
# Jump go up.
 
= VRC SDK 2 Methods =


= Inclined Plane Method (Avatar 2.0) =
=== Inclined Plane Method ===


== Prerequisites ==
==== Prerequisites ====
* VRCSDK2
* VRCSDK2
* A working avatar
* A working avatar
* Some experience with Unity
* Some experience with Unity


== Process ==
==== Process ====


# With your Unity project open, right-click on your avatar's root node in the scene hierarchy.
# With your Unity project open, right-click on your avatar's root node in the scene hierarchy.
Line 33: Line 163:


However, you will want to toggle this ability with a gesture or emote, otherwise you will always be in "flight mode". You will want to toggle the ''Fly'' node we made earlier.
However, you will want to toggle this ability with a gesture or emote, otherwise you will always be in "flight mode". You will want to toggle the ''Fly'' node we made earlier.
== Inclined Plane Method (Avatar 3.0) ==
Same method, but with a few tweaks. Currently being tested.
# Right-click on your avatar's root node in the scene hierarchy.
# Select '''Create Empty''' from the context menu.
# Rename the new GameObject to ''Fly'' or something memorable.
# Right-click Fly in the scene hierarchy.
# Choose '''3D Object > Cube'''.[[File:Unity 2020-11-02 20-20-40.png|thumb|What your scene hierarchy should look like.]]You should now see a Cube under the Fly object.
# Select Cube.
# In the Inspector tab, set the following:
#* Rotation:
#** X: -15
#** Y: 0
#** Z: 0
#* Scale:
#** X: 2
#** Y: 0.4,
#** Z: 5
# Uncheck the checkbox next to ''Mesh Renderer'' to disable rendering the cube.
# Make sure ''Box Collider'' is still checked.
Now you just need to make a toggle for ''Fly''.


== References ==
== References ==
<references />
<references />

Latest revision as of 00:57, 17 November 2020

Here's how to add the ability to fly to your avatar.[1]

Warning: This entire feature relies on a physics bug, which may be fixed in the future.
Note: This guide was written in Unity 2018.4.20f1 on Windows 10. YMMV.


VRC SDK 3 Methods

Inclined Plane Method

Same method, but with a few tweaks. Tested by N3X15 (talk) 18:57, 16 November 2020 (CST)

  1. Right-click on your avatar's root node in the scene hierarchy.
  2. Select Create Empty from the context menu.
  3. Rename the new GameObject to Fly or something memorable.
  4. Right-click Fly in the scene hierarchy.
  5. Choose 3D Object > Cube.
    What your scene hierarchy should look like.
    You should now see a Cube under the Fly object.
  6. Select Cube.
  7. In the Inspector tab, set the following:
    • Rotation:
      • X: -15
      • Y: 0
      • Z: 0
    • Scale:
      • X: 2
      • Y: 0.4,
      • Z: 5
  8. Select the icon on the far right of the Mesh Renderer component.
  9. Choose Remove Component.
  10. Make sure Box Collider is still checked (enabled).
How everything should look.

Now you just need to make a toggle for Fly.

Toggles

  1. Create an animation to enable the Fly object, called Fly On.
    1. Duplicate the avatar in your scene. Name doesn't matter, you can leave it as default.
    2. Open your Animation tab. (Window > Animation > Animation)
    3. Make absolutely certain you have selected the DUPLICATE avatar in your scene.
    4. In your animation tab, click the Create button.
    5. Save the animation somewhere convenient, and name it Fly On.anim.
    6. Click Add Property.
    7. Click the + icon next to Fly > Is Active.
    8. Click the keyframe diamond at the end of the timeline.
    9. Press delete.
    10. Click the keyframe diamond at the beginning of the keyframe.
    11. Check the checkbox next to Fly: Game Object.Is Active to make it active for that keyframe.
    12. Click on the frame line immediately after the 0:00 mark.
    13. Add a new keyframe using the Add Keyframe Add Keyframe button.
    14. Make sure that Fly: Game Object.Is Active is still checked.
  2. Add an animation to disable the Fly object, called Fly Off.
    1. Perform the same steps as above, but name it Fly Off, and uncheck the Fly: Game Object.Is Active checkbox.
  3. Delete the duplicate avatar.
  4. Make an expression menu object for your avatar.
    1. Right-click your avatar's assets directory in the Project View.
    2. Create > Folder named Menus.
    3. Right-click the new folder.
    4. Create > VRChat > Avatars > Expressions Menu.
    5. Name it Avatar Root Menu.
    6. Select the avatar's root node in your Scene Hierarchy.
    7. Under your VRC Avatar Descriptor, expand the Expressions section.
    8. Drag Avatar Root Menu into the Menu slot.
  5. Make a parameters object for your avatar.
    1. Right-click your avatar's assets directory in the Project View.
    2. Create > Folder named Parameters.
    3. Right-click the new folder.
    4. Create > VRChat > Avatars > Expression Parameters.
    5. Name it Avatar Params
    6. Select the avatar's root node in your Scene Hierarchy.
    7. Under your VRC Avatar Descriptor, expand the Expressions section.
    8. Drag Avatar Params into the Parameters slot.
    9. In an empty slot, add an Int called Flying.
  6. Add a new toggle control to your menu.
    1. Click on the new menu in your assets.
    2. Ensure the Active Avatar is
    3. Click Add Control.
    4. Set the Name to Flying.
    5. Leave Icon as None.
    6. Set Type to Toggle.
    7. For Parameter, select Flying, Int from the dropdown.
    8. Set Value to 1.
  7. Make an FX Animator.
    1. Right-click your avatar's assets directory in the Project View.
    2. Create > Folder named Animators.
    3. Right-click the new folder.
    4. Create > Animator Controller.
    5. Name it Avatar FX.
    6. Select the avatar's root node in your Scene Hierarchy.
    7. Under your VRC Avatar Descriptor, expand the Playable Layers section.
    8. Click the Default FX button to override it.
    9. Drag the new Avatar FX animator into the FX slot.
  8. Open your FX animator by double-clicking on it.
  9. At the very top, select the Parameters tab.
  10. Click the button.
  11. Select Int.
  12. Type in Flying (case-sensitive).
  13. Leave the default value as 0.
  14. Go back to the Layers tab.
  15. Create a new layer using the + button.
  16. Double-click on the layer's name.
  17. Name it Flying.
  18. Click the white Gear icon on the far right of the new layer's name.
    1. Set Weight to 1.
    2. Leave Mask set to None.
    3. Ensure Blending is Override.
  19. Select the layer by clicking on it.
  20. Drag Fly Off into the graph. It's highlighted in orange, so this is our landing state, where the animation controller will sit by default.
  21. Drag Fly On into the graph.
  22. Right-click the Fly Off node in the graph.
  23. Select Make Transition.
  24. Click Fly On to finish making the transition from Fly Off to Fly On.
  25. Click the new Fly Off -> Fly On transition.
    1. Uncheck Has Exit Time.
      • You will get a warning, ignore it. We're fixing it in the next step.
    2. Click the + button under Conditions.
    3. Select Flying from the first dropdown.
    4. Select Equals from the second dropdown.
    5. Enter 1 in the textbox.
  26. Create another transition between Fly On and Exit.
    1. Uncheck Has Exit Time.
    2. Add a condition.
    3. Select Flying from the first dropdown.
    4. Select Not Equals from the second.
    5. Enter 1 in the textbox.

Usage

  1. Enable the Fly object.
  2. Move forward and jump, or fall off of something.
  3. Move forward to go up.
  4. Move backwards to go down.
  5. Strafe to stay at the same level.
  6. Jump go up.

VRC SDK 2 Methods

Inclined Plane Method

Prerequisites

  • VRCSDK2
  • A working avatar
  • Some experience with Unity

Process

  1. With your Unity project open, right-click on your avatar's root node in the scene hierarchy.
  2. Select Create Empty from the context menu.
  3. Rename the new empty GameObject to Fly or something similar.
  4. Right-click Fly in the hierarchy.
  5. Select 3D Object > Cube.
  6. Select your new Cube in the hierarchy.
  7. In the Inspector, set the scale of Cube to:
    • X: 2
    • Y: 0.4
    • Z: 5
  8. Set the rotation of the X axis to -30.
  9. Disable the Mesh Renderer.
  10. Make sure Box Collider is enabled. Leave it at default settings.

Your cube should now look like this:

Ready for take-off.
Ready for take-off.

However, you will want to toggle this ability with a gesture or emote, otherwise you will always be in "flight mode". You will want to toggle the Fly node we made earlier.

References

  1. Rampag3, How to Make a Flying Avatar https://www.youtube.com/watch?v=w28WejN9MMQ