Hi I am new and creating a multiplayer game. I forked the tutorial (could not get it to work without forking) and change it. I am trying to add it so “Other” has animation and Rotate to face different directions but I can’t seem to get it to work
Hello @Coder ,
You have forgot to update the updatePosition() function in network.js. It seems to not send the data.rot variable you are looking for. You also need to incorporate the data.rot variable into the movePlayer() function. as for animation, you’d probably need to send out the “state” that is happening as a string and play the animation on the other entity in the client side in code.
Hey @Coder, how did you try to send the data.rot variable? It seems from the error that data is not defined in the context that you have tried to call it in. Can you please send the script where you are trying to do this? It’ll help us find the issue a lot better.
var rotation = this.players[data.id].entity.findByName("Model").getEulerAngles().x;
? If that is the case, you can observe that in previous methods, data was passed as an argument. In updatePosition however, you are not passing any arguments. Therefore, the method does not know what data is. You should study the tutorial carefully in terms of how the position update is being handled, and then do something similar for rotation.
If there is something you don’t specifically understand in the code shown here, please ask . But working with rotation the same way as has been done above with position should be moderately easy. Multiplayer isn’t the most basic concept in game development, but you should be able to achieve what you want to if you carefully study the tutorial and also the sample project.
@DevilZ Sorry I did not see your reply I was messing with animations. I think I know how to do the rotation but i need some help Do you know how to do first person movement with mouse controls but use rotate instead of Eulerangles?
Is this to send the rotation via the multiplayer server? You seem to be sending the euler angles anyway via the server, I’m curious as to why you would want to do this?
If it is indeed the name of an entity, you can get the associated entity by doing this.entity.findByName and searching by the ID. API Reference on findByName can be found here.
I am pretty sure it is defined because it shows everything about it also it was two big to fit everything.
I know it is OtherModel is defined as well because when I change EulerAngles to rotate it works until you reach 360 degrees the instead of keeping on going it turns back around (i think this happens because rotate does not understand the number past 360).