Adapting Shooter example to Ready Player Me: spine

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
XyrisKenn
Posts: 17
Joined: 20 Nov 2022, 08:32

Adapting Shooter example to Ready Player Me: spine

Post by XyrisKenn »

Hello, I've successfully added a downloaded Ready Player Me (RPM) prefab into the Shooter example's Random Player Characters. All that's needed is using the Cowboy Animator; it drives the Masculine RPM Avatar file accurately.
My RPM prefab animates and moves properly at runtime, and is synced correctly to other players' runtime exe.

Environment: Unity 2022.3.17, URP. I've made my own Dance Floor project using the SF2X Buddy List and Shooter examples. I've a custom Game Controller script combining the Buddy messaging and the Shooter GameManager script. I've removed all the shooter-specific health, stats, shooting, etc functions, since all I need are transforms, rotation, walk, run, jump etc animations. References to the SF2X_GameManager in the character controller script is replaced now with references to my custom game controller script. This all works now.

Problem: "Spine" isn't recognized as a child component of my model, leading to errors in the console (spline field in the character controller is empty).
Test: if during runtime I fill the SF2X_CharacterController's 'Spline' field with my RPM avatar's Spine node, the errors stop.

Notes:
- The RPM avatar setup matches the Cowbow avatar in Unity (avatar meaning the Unity Avatar file that matches bones to spine, hip etc).
The Spine node is the same name and placement in both Unity Avatar setups.
- RPM downloaded prefabs use the Mechanim animator in its model settings, but the prefab uses the Unity Animator component, with the "SF2X_Animator" controller in the 'Controller' field so everything moves and syncs properly.

- Line 165 in the SF2X_Character Controller refers to the AimIK type. This script is attached to the Cowboy's Pistol model, attached to the Cowboy armature's right hand.
- I added a simple cube in the same place on my RPM model armature, and added this AimIK script to it.

Expected outcome: The SF2X_Character Controller script should locate the Spine node in my armature, and fill that field for me.
Actual outcome: doesn't work; the Spine field is not filled, leading to errors.

Question: Is the AimIK needed, and is there a likely reason SF2X_CharacterController isn't finding "Spine" in my RPM model?

My model is for dance clubs, and doesn't need this gun item. I could substitute a cell phone model, but in any case the spine filed is not filled.
The spine node in my RPM avatar is not being seen, but the location, name and position in the Avatar definition is the same as with the cowboy's prefab.

Update: replacing line 168 in SFX_CharacterController with line 175 fills the Spine field correctly, and the errors stop.

Code: Select all

if (isPlayer)
 {
     this.transform.GetComponentInChildren<SF2X_AimIK>().isPlayer = true;
     spineTransform = animator.GetBoneTransform(HumanBodyBones.Spine).transform;
     // spineTransform = GetComponentInChildren<SF2X_AimIK>().spine;
 }
 else
 {
     spineTransform = animator.GetBoneTransform(HumanBodyBones.Spine).transform;
 }
Attachments
RPM avatar example.jpg
(162.68 KiB) Not downloaded yet
User avatar
Prof_PP
Posts: 126
Joined: 07 Dec 2007, 08:53
Location: Austria
Contact:

Re: Adapting Shooter example to Ready Player Me: spine

Post by Prof_PP »

Hi XyrisKenn, Is the AimIK needed for your application? No, it is only there to animate the character for the aiming up and down with the camera position.

You can safely remove this and also any references to the Spine. In fact, when we rewrote this example for Godot, we did not use the Spine, as the Godot engine did not support this in the same way that Unity does. We opted for having the Skeleton3D to follow an unrendered object. The end result is the same, actually almost better in hindsight. Perhaps you can compare where we changed the Godot scripts (C#) and it may give you a better idea of what you can remove.

Hope this helps.
Post Reply