Alex10 Posted December 13, 2014 Share Posted December 13, 2014 I do play on websocket and I have a problem with the task motion bullet after the server response.1) When clicked I call a function selfBullet from class bullet and sent to the server the camera position and the player id.window.addEventListener("click", function() { var bul = new Bullet(); bul.selfBullet(); ws.send( JSON.stringify( { 'e':'shoot', 'id':player.id, 'pos':camera.position, 'dir':camera.cameraDirection } )});2) Server for all other players return these values and calls function remoteBullet from class bulletws.onmessage = function(event){ var bullet = new Bullet(); bullet.remoteBullet(msg.id, msg.pos );}3) And then there is a problem. in registerBeforeRender added to the motion vector bullets constant but it looks pretty chaotic.this.remoteBullet = function(player, pos, dir){ var ctr = 0; bullet.position = new BABYLON.Vector3(pos.x, pos.y, pos.z); scene.registerBeforeRender(function () { bullet.position = new BABYLON.Vector3(dir.x*ctr, dir.y*ctr, dir.z*ctr); ctr += 1; });};How to get the right direction to draw the bullet movement after the server's response? }example http://pauluskp.com/babylon Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 13, 2014 Share Posted December 13, 2014 are you sure that your Vector3 return 'float' ?. but I do not know if it'll solve your problem.scene.registerBeforeRender(function () { bullet.position = new BABYLON.Vector3(parseFloat(dir.x*ctr), parseFloat(dir.y*ctr), parseFloat(dir.z*ctr)); ctr += 1.0;});When I test your link, I see no problem. Quote Link to comment Share on other sites More sharing options...
Alex10 Posted December 13, 2014 Author Share Posted December 13, 2014 No, did not help Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 13, 2014 Share Posted December 13, 2014 But I do not see your problem, when I test everything works properly.I tested with google chrome.What's your problem more precisely ? Quote Link to comment Share on other sites More sharing options...
Alex10 Posted December 13, 2014 Author Share Posted December 13, 2014 The problem is that the second player who shot sphere does not see how it flies sphereFor some reason, the scope of the center of the screen is moving in the wrong direction Correctly only when shooting in the first person in function this.selfBullet Quote Link to comment Share on other sites More sharing options...
Alex10 Posted December 13, 2014 Author Share Posted December 13, 2014 Please see video:https://www.youtube.com/watch?v=wGxtl3qTn1I#t=14sThe left of the first-person shooting player and everything is fineRight rendering server response is already there the wrong direction Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 13, 2014 Share Posted December 13, 2014 I feel that there is a problem with the placement of cameras for player 1 and player 2. something does not seem logical to me when comparing the 2 scene. left the track player a green box and red box close to him.the player has the right to see a red box and green box but close too, that gold should be away This player there because it is close to the other if one compares the distance of each player. A player should have the boxes near him and the other away. Sorry for my bad english, but I think that there is something not coherent with your network. Quote Link to comment Share on other sites More sharing options...
Alex10 Posted December 14, 2014 Author Share Posted December 14, 2014 I found a mistake already. I made a mistake by passing "camera.сameraDirection" because for example the camera moves back and forth bullet, so the motion looked very wrong.I will try to convey direction of the shot using "pickInfo". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.