A key aim for me has been trying to implement a full body avatar for the player to inhabit in VR.
To achieve this I knew I couldn't model something in time so I settled on a Noir Character pack from the unreal engine marketplace (I'll be going over a more in depth review on use of assets- the pro's and con's that I've found so far towards the end of production.).
The key here was I needed the body to be responsive to the players inputs but convincing enough not to take the player too far out of the experience. The solution seemed to lay in using IK to simulate the players arms inside of VR to re-create the movement in game. On top of this I wanted to implement some type of physics check to make sure that the player cannot easily 'clip' through the world i.e a hand that goes through walls but equally didn't collide with itself either which would cause a host of other issues and above all only take the player outside of the experience.
This presented several obstacles to overcome-
1) I personally am not an expert in IK or animation. I have used both in the past but only at a surface level and this will be my first full exploration into the topic.
2) It had to look good enough and work well enough- a VR avatar is getting more and more complicated as developers further explore what's possible. For example Boneworks had a full body IK solution- this is beyond my skill and scope for this project.
3) Time. The implementation of this would probably have to be very basic if I couldn't do it in a reasonable time then I'd essentially only have a very good VR avatar at the end of this process and not much of a game. This isn't too much of a concern as there is value and merit in a great VR avatar but in terms of a project management point of view- it really needed to be completed as soon as possible so that I could start work on other key areas.
The first stage I implemented physical animation and FABRIK, having tried two bone IK and not being satisfied with the results. This caused some interesting physic's issues, where the player arms would twist and contort in very unrealistic ways.
The next stage was refining and fixing FABRIK wasn't working as well as it could and when implementing animations for the players lower body I found issues with updating the skeletal mesh location vs. the players actual camera position- completely breaking the immersion and the collision versus my key aims. I took the decision to go back to research when I found the UBIK pug-in on GIT.
 |
| UBIK implementation of Animation Blueprint |
The upper body IK (UBIK plugin) handle s the mesh bones from the spine upwards, everything lower is handled by a simple blendspace that gets movement and speed to use walking animations that I got from the third person starter animation pack. I'm happy with this for the moment but if I wanted to build on this I would add leg IK so the characters legs matched the in game floors better- however when I tried to implement this I encountered too many issues that would take time away from the rest of the project so the animation only approach was kept for now. Once again this is something I'd like to develop further but the time constraints mean that I have to keep features of the project in scope.
This solved a large amount of issues once I'd removed my old blueprints and done some tweaking. The physical animation's at present have broken the grab function in UE 4.27 to enable the 'pick' up of actors but I suspect the issue is related to the collision trace so I'll need to re-build that. The next stage is trying to set up a physical grab- I suspect that this will be more of a challenge and instead I'll fall back to collision trace then on hit insert item into a socket plus animation pose.
Getting physics to work on the player body itself was another large challenge and one that went through many iterations as this would be key to selling the player the idea that they physically inhabited this virtual world - as they'd be able to respond to it almost as well as they could in real-life.
 |
| Player blueprint showing several revisions. |
I explored constraints and physics handles as options and I suspect if this where to expand as a project I would look into these further but based on my current implementation they did not perform as expected, they would cause the player body to glitch in unexpected ways such as jump around the environment and judder or cause unnecessary strain on CPU performance which led to hitches. I have left the old blueprints in the player Blueprint to show the various iterations.
 |
| updating the player location final version |
The next task was to update the player skeletal mesh whenever they moved as for this project I elected to use thumbstick movement over teleporting, this is because I wanted to make sure that the player always inhabited the avatar body, and this led to its own interesting challenges as by default Unreal engine utilises teleportation as the primary method of movement for VR projects rather than smooth movement. I used the pawn movement system that's used by characters by default and the character movement system that is also there. The player body was still the problem however, because as the player moved in game it was not updating the collision of the virtual position of the character as they moved allowing the player to 'step out' of their character.
The first iteration of this blueprint was overly complicated, and I used to call it 'ontick' which meant every frame and as Vr usually needs to be 90- 120 FPS, it was very accurate but very performance heavy.
 |
| Older more performance heavy implementation of player location |
Instead I took the 'onEventplay' function and added a call by time on the created function which is updated every 0.2 seconds and this meant that the performance was much better and gives more overhead for adding other mechanics later on, because I now have that gain in performance over the old code. It also allows me to either speed up or slow down the check depending on how often the player moves- as I want the player to be fairly accurately mapped in the project 0.2 seemed a reasonable compromise between checking too often or not enough which would lead the player movements to feel as though they where juddering.
I have uploaded a short video that demonstrates the first working iteration. I'm certain that I will make further tweaks and changes as the project progresses
Misc:
I have a theory that I will not have time to explore but I suspect having a 2nd hidden skeletal mesh with each body set to constrain the visible mesh (which would have collision disabled) would work very well for physics interactions but again, I have spent too long getting to this point and now need to focus on the gameplay mechanics and level design- although I'm using assets I still need to make sure they are all suitable and work correctly.
Note: 23/11/2021: The Grab not working is an engine problem and only happens when the player blueprint is opened if the project is opened but not the player blueprint the 'grab' issue does not occur. There is also an engine bug that seems to be triggered by use of physical animation in 4.27 that has been in the engine since 4.26 and carries over to the 5.0 early access. This does mean that I've had to cut back on some of the physical animation aspects such as fingers bending when they get too close to a surface- this could also be done in animation but given how much time I've spent on finishing the player avatar to the point where I'm happy with it- it's something that I will come back to towards the end of the project if I have time.