Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Jeston 1 · Oct 04, 2010 at 07:01 PM · fpsnetworkfiring

RPC causing chugs / performance

To those that know unity far more than me :)

I have a weird issue in a networked fps... Nothing particularly fancy is happening. I have a gunManager with its own NetworkView (state sync off) attached to a node called 'Weapons' which is some descendant in my player object hiearchy: which also has NetworkView w/ synchronized compressed data.

The GunManager is straight foward, it checks to see if the player has fired then RPC's when the shot is made with RPCMode.Others so that they can display the bullet/rocket/etc....

if (!LocalPlayer) { return; }

if (Input.GetButtonDown("Fire1")) { //... gets info on camera float distance = SelectedGun.Range; bool hit = Physics.Raycast(transform.position, worldDirection, out info, distance);

if (hit && info.collider.gameObject.tag == "Player") { //calculates local damage, updates local score, etc... }

 networkView.RPC("FiredOneShot", RPCMode.Others, transform.position, worldDirection, info.normal, info.distance, SelectedGun.GunID);
 FiredOneShot(transform.position, worldDirection, info.normal, info.distance, SelectedGun.GunID);

//... }

 [RPC]
 public void FiredOneShot(Vector3 origin, Vector3 direction, Vector3 normal, float distance, int gunID)
 {
     Debug.Log("Player Fired: ");
     GunData.GunType type = GameData.Instance.GunData[gunID].Type;
     if (type == GunData.GunType.Rail)
     {
         if (distance < 5)
         {
             distance = 300;
         }

         Quaternion q = Quaternion.FromToRotation(new Vector3(0, 1, 0), direction);
         Transform t = (Transform)Instantiate(LazerPrefab, origin, q);
         t.localScale = new Vector3(0.2f, distance, 0.2f);
     }
 }

Given this, my lazerprefab is just a cylinder, but for some reason anytime a player who isn't the server 'fires', they have a local chug. But the server does not experience this. In fact, if the server fires alot everyone in the game chugs. The 'chug' is like a 5-10 FRAME lockup(drop) which is very disorienting. I am pretty sure this is the standard way of architecting networking for a gunshot. At first I thought it was the local Instantiate in the Rpc: FiredOneShot, but if I completely comment this function out I still notice the chugging. Has anyone else come across this or have suggestions to try out ?

Appreciate the advice, ~J

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jeston 1 · Oct 06, 2010 at 07:20 PM

It turns out that when I upgraded to Unity 3.0 this problem has completely gone away, so for those experience issues with your networking the older unity did a very bad job with state synchronizing that must have been fixed in unity 3.0, I didn't change any of my scripts and now its running smooth as butter...

strange..

Comment
Add comment · Share
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
0

Answer by Dreamora · Oct 04, 2010 at 07:39 PM

your code is missing likely the most important check before it fires at all: "is time since last fire > firedelay" (and is firedelay reasonably large for network usage at all).

without that you basically flod the network which means that it will die down rather fast.

Comment
Add comment · Show 1 · Share
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 Jeston 1 · Oct 04, 2010 at 09:51 PM 0
Share

yeah I make that check I just didn't post everything I felt was just related to the communication layer as opposed to any real local logic... The chug occurs whenever ANY RPC function is called it seems, when I do an ammo pickup, a gun firing, a respawn, a player leaving the server... and I am following all the practices of the other tutorials :(

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

No one has followed this question yet.

Related Questions

Multiplayer FPS Fail 4 Answers

Network? controles backwards? 1 Answer

A name For the Character Please Help 3 Answers

Bullets going wrong direction 1 Answer

Network fps swap cameras 1 Answer


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