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 /
  • Help Room /
avatar image
0
Question by Stevoyd · Jul 25, 2021 at 09:39 PM · cameramultiplayermultiplayer-networking

MLAPI - Lost with instantiate

I'm new to Unity development, but not new to development. I'm looking to build a multiplayer framework over the next few years that I can then start to use to build multiplayer first-person-viewpoint games from within it.

I've completed both of the tutorials; HelloWorld & GoldenPath. Neither of them reference where the instantiate component is, or how/why it currently creates a player prefab object at client connect when there's no script written in the tutorial that covers this.

I suspect its something to do with the pre-built scripts, but they're mindblowing to read through at the moment when I'm just starting out. I simply want my camera object to be attached to my prefab, and have a unique camera for each player... I can't find any good answers for Unity 2020.3 with MLAPI.

For reference, my camera object has been made into a prefab now:

 PlayerCamera (Prefab Asset)
 Camera: Disabled
 Audio Listener: Disabled
 NetworkObject: NetworkObject.cs
 Script: PlayerEnableComponents.cs

PlayerEnableComponents.cs:

 using UnityEngine;
 using MLAPI;
 
     public class PlayerEnableComponents : NetworkBehaviour
     {
         public Camera Cam;
         public AudioListener Listener;
 
         private void Start()
         {
             if (!IsLocalPlayer) return;
 
             Cam.gameObject.SetActive(true);
             Listener.gameObject.SetActive(true);
         }
     }
 
 

EDIT: For reference, I've taken this from the MLAPI guide:

Scene Objects# Any objects in the scene with active NetworkObject components will get automatically replicated by MLAPI. There is no need to manually spawn them.

There are two modes that define how scene objects are synchronized.

SoftSync# SoftSync is the default and recommended mode for synchronizing scene objects.

When using SoftSync MLAPI will just synchronize existing scene objects with each other. This allows scene objects to be non prefabs and they will not be replaced, thus keeping their serialized data.

The above does not occur in my project. New items are created, but they are not being 'Soft Synced' as each spawn of the new prefab replaces the last for all players (and the server).

Comment
Add comment · Show 1
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 Stevoyd · Jul 25, 2021 at 08:09 AM 0
Share

Why has this been moved to moderation?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GetLitGames · Jul 26, 2021 at 12:07 PM

If you configured the network manager to use a default prefab like the web page describes, that prefab will be instantiated any time a new client connects. So you don't need to instantiate anything for a player that connects. If you have your PlayerEnableComponents script on your player prefab, it should work fine.

As described on this page: https://docs-multiplayer.unity3d.com/docs/develop/tutorials/helloworld/helloworldintro/index.html

for future objects, ones that are not set as the default player prefab, it should work as you expect - instantiating anything that is a NetworkBehavior will replicate itself automatically. If you have any problems or you need something more mature/stable, or fits your requirements better you should look at Photon Bolt.

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

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

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

Set Main Camera in Networkmanager 1 Answer

Multiplayer Camera Problem! Help me plase 3 Answers

How can I change the viewport rect of two active cameras at runtime? - Splitscreen Multiplayer 1 Answer

NetworkServer is not active. Cannot spawn objects without an active server. 0 Answers

Unity Photon how to show arm/gun movement with mouse to other players.,Unity Photon: How to show arm movement to other players 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