[SOLVED] setLocalEulerAngles() weird behavior

I have code which ensures the Character mesh is facing the proper direction when a player is spawned, the following code fixes mesh rotation when a player joins. (Only for pre-spawned players)

Although the mesh rotation now works each time a new player joins, the eyewear that was on the character lost it’s position and rotation.

The following is the hierarchy setup for the character mesh on the NetPlayer entity:

Screen Shot 2021-10-12 at 10.28.30 AM

Below shows how it should look when rotating via code, this view is from newly-spawned players though. It works how it should / has no effect towards eyewear & gear.

Not sure what’s the best way to go about rotating strictly meshes with PlayCanvas so I used the setLocalEulerAngles() which seems to be the only one that works.

Any suggestions? I’m using the ReadyPlayerMe API for avatars so eyewear and gear are included with the asset model.

It seems that you’re maybe rotating only part of the hierarchy that contains the character, but does not contain the glasses. You should go up to their shared parent / possibly even the root of the whole hierarchy, and rotate that entity.

Hmm now is this because of the use of setLocalEulerAngles function itself?

Because that would mean rotating the Player entity which is not what I want since that happens upon the player moving + rotating the camera.

Is there an alternative to the function, setRotation and setLocalRotation(-90, 180, 0) makes the character mesh disappears / leaves the viewport.

Like stated, everything is included in one .glb loaded from url. The glasses / accessories aren’t separate in terms of files. The character mesh loads this asset, the Player entity is it’s parent with scripts for movement, etc.

Can you use the devtools here to show the runtime entity hierarchy? https://github.com/yaustar/yaustar.github.io/tree/master/playcanvas-devtools

It does look like that perhaps you are rotating the wrong entity.

setLocalRotation is expecting a quaternion, not euler angles by the way.

I do believe ‘RPMCharacter’ is my target entity, I don’t understand why you’re suggesting it isn’t :frowning:

I forgot all about this tool, thanks for the reminder.

How would I go about replicating this rotation with a quaternion? This is how the Character asset is loaded into the ‘RPMCharacter’ hierarchy entity.

Using the tool, see if you can hunt down where the glasses are in the hierarchy. It does look like you rotating the correct entity, so if the glasses are a child of that entity, I’m not sure what is going on without a repro.

1 Like

This only seems to occur when I use .setLocalEulerAngles(-90, 180, 0) not .setLocalEulerAngles(360, 0, 0) which is weird to me though the later doesn’t keep constant rotation for each player spawn.

I’ll continue to play around with it, just having a hard time rotating other than setLocalEulerAngles()

If you can share a public project that has the issue with glasses, I can take a closer look

I’d rather not have it forked around, may I invite you instead?

Yep, that’s not a problem either. If you do a private fork and give yaustar edit rights, that would be great

1 Like

Thanks for giving it a look, just sent the invite.

Refer to the network.js script around lines 225-414 & 1174 respectively.

Host a room, then join the same room in another tab. Issue occurs on host of the room.

(Select a default ReadyPlayerMe avatar with glasses)

Looks fine to me?

Side note: Whats the reason for not using Mixamo’s Ready Player Me rig and going the route of renaming the nodes?

I can’t reproduce this on the fork you have given me. Do I need a particular type of avatar?

1 Like

Because the animations wouldn’t work for some reason so I had to manually rename them.

If you remove line 1174 can you tell me why the character mesh just flips upon multiple players without rotation?

The glasses issue only really occurs because of that line of code, I only have that line because I can’t figure out why the mesh just rotates randomly without it.

Seems to be specific to those glasses or random?

The player node hierarchy is different from the netplayer:

The player only has one Armature child and the net player has two. Also hips is a child of Armature on the player but not on the net player

1 Like

It seems just those glasses, I guess I have to fix the bone references then…?

I couldn’t figure out why the mesh rotates, I added that line which fixed the rotation problem, yet created another just for those glasses.

I would like to ultimately not have to do any rotation stuff since it’s not required by the default dummy mesh at all. Yet for the ReadyPlayerMe, it rotates at different axis when another player joins

If you remove the animations off the net player and comment out the rotation on line 1174, the t pose model looks fine with the glasses:

The issue is related to the animations and/or the renaming of bones.

As you are referencing by child index to do the renaming, this can be very error prone if something is moved/added/removed by the ReadyPlayerMe service:

                var spine = hips.children[0];
                var spine1 = spine.children[0];
                var spine2 = spine1.children[0];
                var neck = spine2.children[0];
                var head = neck.children[0];
                var headTopEnd = head.children[0];

                var leftShoulder = spine2.children[1];
                var leftArm = leftShoulder.children[0];
                var leftForearm = leftArm.children[0];
                var leftHand = leftForearm.children[0];
                var leftHandThumb1 = leftHand.children[0];
                var leftHandThumb2 = leftHandThumb1.children[0];
                var leftHandThumb3 = leftHandThumb2.children[0];

I would seriously consider using Mixamo’s Ready Player Me rig as shown here: Mixamo Animations for UE4 - Ready Player Me

Or at the very least, create a new project that just loads the model GLB and does the retargeting so you can debug in isolation.

1 Like

I think that may have did the trick @yaustar, removing the bone renaming code fixed all issues!

You’re literally a life-saver like always, damn I love this community!

Even through silly mistakes, you guys find a way to help solve issues they cause. :sunglasses:

2 Likes

Er, what did I fix and how did I fix it :sweat_smile: ?

I was in the middle of making a separate example project here: https://playcanvas.com/project/839886/overview/ready-player-me-x-mixamo

1 Like