Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by p1g30n · Apr 16, 2017 at 09:09 PM · networkingnetworkspawnsyncclient-server

How to avoid spawn delay on client?

Hello. I try to create online top-down shooter. Character rotation is controlled by mouse. So on the server there is no problems, but on client bullet spawning is delayed. When I turn my character and shoot, bullet spawns on the position where characters gun was few moments ago, but on the server everything is fine. Also I add force to the bullet after spawning.

     [Command]
     void CmdShoot()
     {
         GameObject instance = Instantiate(bullet, playersGun.position, playersGun.rotation) as GameObject;
         instance.GetComponent<Rigidbody2D>().AddForce(playersGun.up * power);
         NetworkServer.Spawn(instance);
     }

That is shooting script.alt text

On the screenshot the lower bullet is servers and upper bullet is clients one. How can I sync it and avoid delay? Maybe someone can help me? Thank you.

capture11111111111111111.png (18.9 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Masterio · Apr 17, 2017 at 09:31 AM 0
Share

I am not good in networking but i thing you should send only coordinates for bullet spawn to the client. Client shoud instantiate it. Here you send whole bullet isntance. Next you should think about object pooling because instantiate objects is havy solution.

avatar image hexagonius · Apr 17, 2017 at 02:33 PM 0
Share

It depends on what you're planning on doing. If you want the bullet to spawn at the gun, you could do that, but then the trajectory would be different from the server. The client might hit someone, but the server didn't and ignores it, which might upset the player. $$anonymous$$eeping both in sync however would result in the player seeing his character in a totally different state all the time. Of course he wants his character to react to his inputs the second he pushes a button. Unfortunately, it's not possible to get everything at the same time, because there's the delay of network traffic. The best choice would be to predict the enemies position at the client side to compensate for the delay. This won't be accurate either, but that's the problem with networking. If I may suggest reading these articles, they give a great understanding of fast paced network games and how they compensate the problems that arise:

http://www.gabrielgambetta.com/fpm1.html

As an additional note: Street Fighter renders several frames beforehand to accommodate for changes due to network lag. But I don't know where to read about it

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

105 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

i'm trying to spawn enemies and it goes well but when i'm trying to scale them it doesn't sync i used [ClientRpc] and it didn't work 1 Answer

SyncVar works with disabled components? 0 Answers

Since switching to using offline & online scenes in the NetworkManager, Clients will not sync (UNET) 0 Answers

UNET Network.Spawn and child objects 1 Answer

Networking bullet spawning issues between Host/Client 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges