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:
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.
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.
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()
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.
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
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];