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 MilloAlejo · Sep 17, 2020 at 02:37 PM · networkingmultiplayermultiplayer-networkingtrailrenderertrails

TrailRender not showing in all clients using Mirror networking

Hi, i'm making an arcade racing multiplayer game where each player prefab has attached two child transforms with the TrailRender component in them.
My player prefab inherits from NetworkBhevaior, i have my ownership & authority logic in it's controller. I also have NetworkTransform for the player prefab and two NetworkTransformChild for each transform that has the TrailRender. Basically i can't make other clients to see the player TrailRender emmiting.
Is a basic trail that simulates a skid. So when the angularVelocity of the car is greater than it's linear velocity it's start drifting and the TrailRenderers are set to emitting = true. The thing is only the player client who's drifting can see the trails, others not.
I tried converting those child transform into prefabs and putting them as spawnable prefabs in the network manager but it didn't work. Also as i mentioned i have in my player prefab those NetworkTransformChild targeting it's child transform with the TrailRender and also doesn't work.
My player prefab hierarchy:
*Car is the parent game object and CHILD_TRAILRENDER 1 & 2 are child of Car with the TrailRender component, the whole thing is my player prefab.
-CAR -CHILD_TRAILRENDERER_1 -CHILD_TRAILRENDERER_2
I set my trail renderers in my player controller as "TrailRender[] skids";
And in FixedUpdate() when i detect that angularVelocity is greater than fordward velocity i have an "foreach TrailRender skid in skids" and set skid.emitting = true. That's all code i have for it. works but not visible for other clients.
Please if someone knows or have an idea of how can i make this trails appearing in all clients it would be good.
Thanks for your time.

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

· Add your reply
  • Sort: 
avatar image
0

Answer by GetLitGames · Sep 29, 2020 at 01:17 PM

Right, this will be a concept that will take some time to understand. The networking library is only transmitting data. What I mean is that you should learn exactly what data it is handling and when it sends and receives because that is the main focus of the networking library.

So, to get back to your problem - your script that turns on the renderer is only running on the local machine (or maybe you are allowing it to run on all machines and it simply isn't working as expected). So when it turns on the trailrenderer, there is no magic that happens to turn it on for all the other clients. The other clients may have that script on them, but that doesn't mean it is functioning. Most people who start out with networking think that the networking code will replicate everything happening on the objects, but that is not the case. They usually make it very easy to enable replicating the position and rotation of gameobjects, but almost anything else needs an understanding of how the networking library works and what options you have to send and receive things.

Besides manually calculating the velocity in the script, you can also send RPCs to other machines telling them to turn on /off the trailrender.

My first question would be what do you mean by velocity? If you are checking velocity from a rigidbody, only the local machine's rigidbody will have any velocity. Most likely the remote copies of your player's vehicle is controlled simply by replicating the transform's position. So you may have a rigibody locally and move the player's vehicle that way (by adding force, having collisions etc), but the only data transmitted to other clients is most likely the position and rotation of the object. In fact, you wouldn't want want the remote copies to be affected by gravity, you would want their rigidbody to be kinematic.

Also, if you are doing server-authoritative control, then only the server should have an active rigidbody allowing gravity and collisions. You generally wouldn't want the remote copies to have gravity and physics turned on because all that should be happening is that the remote copies follow whatever happens on the server. So only the server needs those things, the remotes are simply puppets. Even collisions - only the server collisions should matter anyways.

So if you are running the same code on every machine, one change that might work is to manually calculate velocity by storing the current position and then in the next frame calculate the direction and velocity of the transform with some math.

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

330 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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 can I send update to all clients from one client in Multiplayer game in Unity3d? 0 Answers

How to decide an asynchronous multiplayer solution for a turn based mobile chess game? 0 Answers

Whats the best beginners tutorial for Photon Networking with Unity 2 Answers

RPC sending Failed 0 Answers

[UNET 5.2] Multiple local authority for 1 object? 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