Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: avatar aiming IK #1611

Closed
2 tasks
avaer opened this issue Oct 21, 2021 · 5 comments
Closed
2 tasks

App: avatar aiming IK #1611

avaer opened this issue Oct 21, 2021 · 5 comments
Milestone

Comments

@avaer
Copy link
Contributor

avaer commented Oct 21, 2021

Overview

We need avatars to aim guns/phones/etc properly when you right click to aim.

Right now there is not much of an aiming implementation (it just rotates the avatar). However there are two existing solutions with might be used.

We need a solution that meets these requirements, as well as looks good. The gun pose should be dynamic, like fortnite or a cool anime.

Requirements

First, we will bind weapons to the wrist (like gun), and we will raycast from the gun to shoot, so the wrist must be very accurate, pointing in the direction of the camera (where the user is pointing). It cannot be glitchy.

Secondly, it should look natural at all angles in the range -PI/2 <-> PI/2, around the hips direction. Why hips direction? Because the hips move independently and can be PI/2 max out of sync with the shooting animation. This is already implemented in the codebase/proposed IK solution.

Therefore, third, this solution to this needs to play nice with the lower body animations, since we aren't replacing the entire animation system right now.

Finally, whatever solution we use should be performant (e.g. not adding more allocations in the frame loop, adding GC pressure, etc.).

Possible solutions

Two approaches were already tested:

  1. interpolate pitch/yaw animations: Pitch/yaw AnimationMixer hack #1612 -- doesn't blend right, needs more math. also the animations are not great yet, but could be improved by the art team
  2. use our inverse kinematics solution: Gun aim IK #1616 -- doesn't look great and isn't perfectly accurate but it feels and plays ok, if we can make it look better

However, there are better solutions with more work -- like for example custom procedural IK for this special case, or a different keyframe mix.

Code points

Nice to have/future work

  • Add firing kickback support on trigger
  • Transplant the finger bones from another animation to give a hold effect

Related issues

#1607

@avaer
Copy link
Contributor Author

avaer commented Oct 21, 2021

Note that using an AnimationMixer blend with the pitch/yaw fbx files looks very tame and bad by default, so I'm going to try to use the IK instead, which looked good before.

Wooblyverse.-.Google.Chrome.2021-10-21.13-03-47.mp4

@avaer
Copy link
Contributor Author

avaer commented Oct 21, 2021

Incorrect blend implementation of the pitch/yaw for reference: #1612

@avaer
Copy link
Contributor Author

avaer commented Oct 21, 2021

Testing the IK solution: #1616

@avaer
Copy link
Contributor Author

avaer commented Oct 23, 2021

Heads up that I merged a functional version of this via #1616

It doesn't look great yet and needs kickback, IK accuracy fixes, and better effects, but it's a starting point.

@avaer
Copy link
Contributor Author

avaer commented Oct 23, 2021

I added pistol kickback with #1624

@avaer avaer closed this as completed Oct 23, 2021
@0reo 0reo added this to the Animations milestone Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants