hi so when another player joins my game it just spawns a capsule but i want it to spawn the player model and i want the player to be able to see the other players animation and movement. Im currently using the default multiplayer script.
Add the player model to the “other”
oh wait i got it sorry
now when a player joins it lags a ton and the game is unplayable
ok i fixed that but it wont play the animation when another player moves
You’ll have to go to your socket.io and make code to catch the player states, so you see the animations to
could you tell me how to do that please? im kind of new
i use the glitch thing btw
and this is my current server script
var server = require("http").createServer();
var options = {
cors: true
};
var io = require("socket.io")(server, options);
var players = {};
function Player(id) {
this.id = id;
this.x = 0;
this.y = 0;
this.z = 0;
this.entity = null;
}
io.sockets.on("connection", function(socket) {
socket.on("positionUpdate", function(data) {
players[data.id].x = data.x;
players[data.id].y = data.y;
players[data.id].z = data.z;
socket.broadcast.emit("playerMoved", data);
});
socket.on("initialize", function() {
var id = socket.id;
var newPlayer = new Player(id);
// Creates a new player object with a unique ID number.
players[id] = newPlayer;
// Adds the newly created player to the array.
socket.emit("playerData", { id: id, players: players });
// Sends the connecting client his unique ID, and data about the other players already connected.
socket.broadcast.emit("playerJoined", newPlayer);
// Sends everyone except the connecting player data about the new player.
});
});
console.log("Server started.");
server.listen(3000);
its the default code
I have no experience myself, as I’ve never made a multiplayer (or at least a good one)
oh ill just make a new thread then