Author Topic: TNManager.Create question  (Read 2505 times)

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
TNManager.Create question
« on: June 30, 2013, 05:22:49 PM »
Hi,

I am using TNManager.Create to create my projectiles in my FPS project, which players can fire at each other. However due to the delay in creating the projectile across the network:

1 - The created projectile spawns in an old position as my avatar is moving at speed
2 - The other player sees it in reverse. So that the projectile is spawning ahead of where he sees me.

I don't currently try and synch the projectile positions as there are a LOT of projectiles at any one time (in the high hundreds) and I am concerned about using the TNAutoSync and sending a lot of packets as a result.

Any ideas? Thanks!
« Last Edit: June 30, 2013, 05:35:46 PM by Voxel »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNManager.Create question
« Reply #1 on: June 30, 2013, 09:53:35 PM »
Why does position differ? The object may get created at a position that's somewhere in the "past", but the avatar of the player that created it should also be in the past, so the two would line up. You need to make sure that the player that's firing the weapon is the one that's spawning the objects -- the same player that should be sending out sync updates for its own position.

It's also often a good idea to sync the begin and end actions instead of creating each projectile individually if you have a rapid-firing gun. For example, player presses the "fire" button and the gun starts firing -- you know where it's firing because you know where the gun is facing (and you should probably send the updated pos/rot when you send the 'fire' message). Keep firing until the button gets released. At that point send out the "stopped firing" message. If there is a hit on another player, send that as well.

This way all you need to send periodically is the pos/rot updates rather than individual create object calls, and the object creation can be done only locally.

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: TNManager.Create question
« Reply #2 on: July 03, 2013, 04:11:20 PM »
I think I get what you are saying :) However I just can't seem to sort it. Here is a video just in case it makes things clearer and just in case I am not explaining myself correctly. So for me shooting the projectile is spawning where I was, and for the other player the projectile spawns where I will be traveling too. Thanks for your patience with me on this!

http://www.youtube.com/watch?feature=player_detailpage&v=cjOJagLvFmk


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNManager.Create question
« Reply #3 on: July 04, 2013, 07:57:27 AM »
You either need to sync the player's position immediately when you fire so that everything is updated at the same time, or you need to make it so that everything is "in the past".

Updating everything at the time of firing is the bandwidth-intensive method. The better method, as I suggested, is to sync the "I started firing" message instead, and each player can take care of spawning their own local bullets at proper intervals until the "I stopped firing" message gets received. This method won't use TNManager.Create at all.

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: TNManager.Create question
« Reply #4 on: July 06, 2013, 12:09:37 PM »
Yep, that did it! Thanks so much for drilling it into my head lol!