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 /
  • Help Room /
This question was closed Apr 02, 2016 at 11:15 PM by Pafk for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Pafk · Mar 30, 2016 at 01:44 PM · networkingspawnclientsynchronizationcommand

Unet NetworkServer.spawn, correcting my workflow: Found no behaviour for incoming Command

I've been trying to get spawning non player objects right and after searching through other asks on the subject I have come to a bit of a standstill in the current state I have two problems, first only the host is able to spawn the object, second only the host is able to see the visual modifications to the spawned prefabs(velocity and position are fine).

My workflow and assumptions are as follows

Vanilla player spawn with no special modification to the network.

What is essentially a factory is added to the player gameobject (assumption : to piggy back off of the player's client authority), each player getting their own factory.

The player makes a call to the factory

The factory makes a call to it'd own [command] function

The factory command instantiates a projectile controller The factory command networkserver spawns the projectile controller The factory command passes values to the projectile controller

The projectile controller takes in all of the passed variables

The projectile controller calls it's own command (assumption: this is redundant because it should already be on the server because of the factories command)

The projectile controller command sets it's position, velocity and spawns the prefabs that make the projectile visual and modifies them

I assume that to fix the problem of visuals I need to extract the prefab modifying calls from the command and have the spawning script send a message to all of the clients to call that new function, though I haven't looked into sending messages yet. I am however, not sure where to go from here on the ability of only the host to spawn projectiles.

Edit 1: After testing with the unity editor as the host client the following error appeared in the

Found no behaviour for incoming [Command:InvokeCmd] on 3rd Person Controller

It appears that based on the error wording that the host can't find the command on it's side. Based on searching that I did the problem is that the other object wasn't spawned on the server. But, I checked in the Editor's hierarchy view and both available player prefabs had the factory script attached.

Edit 2: I attempted to add a command to the player controller that sets the variable that points to the currently used factory. After adding the command and replacing the relevant attempts to set the variable with the command version the Unity editor crashes when a client attempts to connect with an error along the lines of There is a player with this playercontrolid already

Any help would be appreciated.

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

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by Pafk · Apr 01, 2016 at 11:27 PM

Solved the more important of the two problems, the ability of the host to recognize commands from the clients.

For anyone that is trying to do commands from abstracted classes like me, make sure that the script calling the command is attached to your GameObject in the Awaken function and not the Start function, otherwise it seems that the server does not recognize the two scripts as being the same.

My finished and fixed workflow is as follows

Player is spawned

Factory is created in the Awaken

User presses correct command

Factory's function is called

Factory calls it's command passing in variables with player location and velocity (this is a fast paced action game so it is important to player immersion that when they shoot their projectile that it fires out from their location and direction, if I relied on the server location a player moving forward and shooting their projectile would/could hit themselves with it, since server-side interpolation would make the player shoot the projectile from where they were 1-2 seconds ago, trying to fix this by changing interpolation settings would result in very, very bad jitters to the point where one player looked like two players next to each other)

Factory's command spawns the projectile base prefab

In the projectile prefab's Awake function it attaches the collider and renderer objects to the projectile GameObject

The Factory calls the projectile's variable setting function and sets relevant SyncVars

In the Start function the size of the collider and renderer are set based on the SyncVars set in the previous step

To help anyone else having similar problem it seems that as far as the initialization process over the HLAPI goes, Awaken is called only on the original client/host, and that Start is called on all clients on which the object is spawned. This is important to solving both parts of this problem.

The script needs to be added before being propagated across the network so that all clients recognize that script as the same for each player.

For the rendering problem it is important because Start is not called until after the current frame is over, this means that you can set variables that will be used by Start in the same frame as you Initialize it.

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 3Dreadnoughts · May 25, 2018 at 03:28 PM 0
Share

$$anonymous$$oving my NetworkBehaviour Creation on Awake solve my problem! Thanks!

Follow this Question

Answers Answers and Comments

131 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 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

How do I make the syncvariable have the same value on both the client and the host?,How do i make the SyncVariable have the same value on both the client and the host (client +server)? 0 Answers

void don't Run which tagged "Cmd" in IEnumrator :( 0 Answers

Client can't answer to Server, Command methods don't work, ClientRPC do 0 Answers

How can i Spawn a different prefab for client? 0 Answers

Player Teleport Not Syncing Across the Network Properly 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