theCapypara / GMnet-ENGINE

A multiplayer/networking engine for Game Maker Studio

Home Page:https://gmnet-engine.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Player sprite change

tytrhex opened this issue · comments

Hello, I'm pretty new to GM and GMnet engine also. I'm trying to change player sprite by the variable. I mean if player is joining the game, he get variable about his sprite. But its just changing the sprite of all players by that variable, so all players for one client look same. Hope you can help me. Thanks.

Sounds like you change sprite_index for all player objects.
You should only change it for the local player.
ex:

with obj_player
{
    if htme_isLocal()
    {
        sprite_index=spr_my_custom_sprite
    }
}

Oh thanks my code for this now look like this. And BTW do you now how to save this lets say client value or sync the sprite so other clients can see each other with different sprites. But realy thanks 👍

if htme_isLocal(){
if(!self.pressed_left and !self.pressed_right and !self.pressed_up and !self.pressed_down){
sprite_index = self.char;
}
} else {
if(!self.pressed_left and !self.pressed_right and !self.pressed_up and !self.pressed_down){
sprite_index = htme_spr_player;
}
}

The sprite should sync via:
mp_addBuiltinBasic("basicDrawing",15*room_speed);
But it only sync it every 15 seconds.

If you want a more precise sync you need a network architecture model that support it. You can build one by follow these tutorials:
https://www.youtube.com/playlist?list=PLfMGRgz7yTw-RtXnPV7a51aoZb3fufzZ9

Im still kinda lost. I dont know how to define other players or instances sprite or in my case character. For now Im using that when player join he get variable of his sprite that is set to him but i dont now how to do it that it will set different sprites for other players. I mean my players is local so it will set him sprite by his variable but i dont know how to define other players and set them their sprite. I hope you understand me because my english is realy bad. Also thanks for support.

Oh never mind i just figure it out.