Jump to content

Keeping an history of the rendered frames


W1lly
 Share

Recommended Posts

Hello Babyloniens,

 

I am currently working on latency-sensitive events such as shooting at another player in the context of a real-time multiplayer game. I would like to be able to check the past positions and animation states of my players.  It would be very handy if I could access my scene object as it was a few frames ago. This way I wouldn't have to reconstruct the scene each time I need to access my player's past positions, and I could directly cast rays on the scene to determine the aiming of the player who is shooting. 

To do that, I was thinking that the best solution would be to keep an history of the past rendered frames.

Is there a way of doing that in babylon.js ?

Link to comment
Share on other sites

Ok I see, thank you for your answer Deltakosh :)

One more question though: how could I save the exact bones position/rotation for a given frame? Also I read that making instances of a mesh would result in all instances sharing the same armature, is that correct? If so, is there a way of "copying" the armature rather than creating a new armature manually?

Link to comment
Share on other sites

Actually, ideally I would also want to save the bones positions. When a player shoot at another player, depending if the targeted player is running/jumping or whatever, the hitboxes won't be in the same position since they follow the armature transformations, which depends on the animation running at this moment.

 

I seem to have solved this, not sure if this is the best solution but still, if someone is interested to know how I solved this:

 - On each rendering frame I just make a clone of my player's mesh and modify its position to reflect the player's position. I also clone the skeleton of the mesh

 - Then, knowing the current frame of the animation being played, I make a scene.beginAnimation between the frame and frame+1, at a speed of 0 (so I end up with the cloned mesh being stuck in the position of the current frame of animation)

 - I store this clone in an array with the length fixed to the number of past positions I want to save, lets say 10 for instance (so there is a mechanism that makes sure the array is always of length 10, deleting the index 0 and adding at the end when the array is full). I also store the exact timestamp of the rendering frame.

 - Know, when casting a ray I can easily choose the appropriate clone by modifying the predicate of the function.

 

Not sure if I am very clear here...

Anyway, I am still open to suggestions  :P

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...