Rotate without using euler angles in multiplayer game makes the entity disappear

cant seem to figure out why but when another player moves/rotates they just disappear.

var Network = pc.createScript('network');

function setCookie(cname, cvalue, exdays) {
  const d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  let expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
function getCookie(cname) {
  let name = cname + "=";
  let decodedCookie = decodeURIComponent(document.cookie);
  let ca = decodedCookie.split(';');
  for(let i = 0; i <ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
  return "";
// static variables = null;
Network.socket = null;
var loggedin=getCookie("prevlogin");
// initialize code called once per entity
Network.prototype.initialize = function() {
    this.player ='Player');
    this.playercam ='PCamera');
    this.other ='Other');

    var socket = io.connect(''); // Glitch hosted server
    Network.socket = socket;
    socket.emit ('initialize');
    var self = this;
    socket.on ('playerData', function (data) {
        self.initializePlayers (data);

    socket.on ('playerJoined', function (data) {
    socket.on ('playerMoved', function (data) {
    socket.on ('killPlayer', function (data) {

Network.prototype.initializePlayers = function (data) {
    this.players = data.players; =;

    for(var id in this.players){
        if(id !={
            this.players[id].entity = this.createPlayerEntity(this.players[id]);

    this.initialized = true;

Network.prototype.addPlayer = function (data) {
    this.players[] = data;
    this.players[].entity = this.createPlayerEntity(data);

Network.prototype.movePlayer = function (data) {
    if (this.initialized && !this.players[].deleted) {
        this.players[].entity.setLocalRotation(data.rx, data.ry, data.rz);
        this.players[].entity.rigidbody.teleport(data.x, data.y, data.z);

Network.prototype.removePlayer = function (data) {
    if (this.players[data].entity) {
        this.players[data].entity.destroy ();
        this.players[data].deleted = true;

Network.prototype.createPlayerEntity = function (data) {
    var newPlayer = this.other.clone();
    newPlayer.enabled = true;


    if (data)
        newPlayer.rigidbody.teleport(data.x, data.y, data.z);
    return newPlayer;

// update code called every frame
Network.prototype.update = function(dt) {

Network.prototype.updatePosition = function () {
    if (this.initialized) {    
        var pos = this.player.getPosition();
        var rot= this.playercam.getLocalRotation();
        Network.socket.emit('positionUpdate', {id:, x: pos.x, y: pos.y, z: pos.z,rx: 0, ry: rot.y, rz: 0});
        setCookie("prevlogin","yes",1);"2D Screen").enabled=false;"Game").enabled=true;

Hi @Granted! Not sure why the entity disappears, but you can’t use setLocalRotation on a dynamic rigidbody. You can try to remove line 90 and replace line 91 with the rule below.

this.players[].entity.rigidbody.teleport(data.x, data.y, data.z, data.rx, data.ry, data.rz);

yes i tried doing that but i only want the y rotation. If i use that snippet then once the player rotates 180 it snaps back to zero not doing a ful rotation only a half one. Also the rigidbody is not dynamic its static.

You can’t rotate a static rigidbody anyway. Then at least it need to be a kinematic rigidbody.

is there a different way i can rotate the player using a rigid body?

What type of rigidbody?

its fine now. i figured out another way to get the rotation to work. thanks for the help

Can you share it here please, so it can help other too?

Im not rotating the main other player. Im now rotating a entity inside of the other player and what i wanted to move and look around now moves inside of the rotation entity. Still dont know why the other player would dissaper though

1 Like

Your other player still has a static rigidbody.

A static rigidbody is not supposed to move or rotate.

1 Like


I think if an entity disappears, you are setting a position or rotation that’s undefined or something like that.

1 Like

yeah maybe

getLocalRotation returns a quaternion which has four components, X, Y, Z, W

In both your network message send and where you use setLocalRotation, you are missing the W component.

dang it thats shy it wasnt working

i could try to help you add me

Thanks for the offer man but i got it working