Still useful 3 years later. Was having problems with this EXACT problem and your way solved my issue instantly. Spent hours just for it to be a simple solution lmao
I'm delighted that this worked for you! I do wonder if there is a better way these days. I've not touched my pick up code recently, I'll have to give it a poke. Thank you!
7:25 well, thank goodness I kept watching before commenting, because the entire time I was thinking "wouldn't it be much simpler to just set the cube's position/rotation as though it was a child of the player, without actually making it a child" 😂 Glad you figured it out and got it working!
Cheers mate! Yes, it is definitely the right decision. Especially when you consider in Clomper it's not just the players that pick up and drop stuff. 👍
Excellent explanations behind the official way and how you implemented it! Setting a parent like that is the kind of thing I'd do in my engine so I hope if I ever give networking a crack I can come up with a similar solution. Good luck moving onto the gameplay for clomper.
Great to see you fixed it in the end! The video was very well explained as well. I hope you can take a breather from all of the network stuff and do some fun gameplay stuff now!
Great video on this, very easy to follow. I was running into the same issue and actually came up with a similar solution to your final solution. I hadn't thought and didn't know about the network wrapper though. Interesting idea, but I feel like the position and rotation matching is a bit easier personally. I did have some issues beyond that though. Whenever I picked up an item and then moved my character with the item being held, it would stutter as if it was a few frames behind and catching up. I changed the update that was setting the position and rotation to a LateUpdate and it seemed to fixed the issue.
So glad that you got the networking issues more or less solved, I saw your tweet and you just seemed so defeated by it but I am glad you were able to defeat it! Also I don't understand networking in the slightest but your explanation of it in Clomper was perfect!
Thank you! I did feel defeated, to be honest. For a long time, I just want having fun. Rewriting the same 2 classes over and over. Thank you for the support!
Thank you! Put multiplayer in early. It's standard advice but it's right. Thank you for the feedback, I'm never really sure how to pitch the mid-level tutorial videos. Hope Micro-Snut is doing well and that the winter isn't too cold for you over there. :)
Question @RobLang, How did you make the pickup work with an offset? When picking up an object It assigns the softparent to the player character object, which works as expected, but when I try to pass in a child empty game object (hand) it does not work for clients. It assigns the hand to the softparent, but never moves. I feel as if the answer would be simple and I'm being silly missing it.
Can you upload some code to somewhere and the images of your player prefab hierarchy so that I can have a look. Or send to my Discord DMs: Rob Lang#7769
Just wanted to say thank you! This helped me out and ended my trial and error headache. The documentation for network transform children isn't at all clear when it comes to carrying objects.
Thanks for the explanation even though it doesn't work for me. Remember when you moved the hand.cs script from the hand to the player? This makes that when on hand.cs:28 you do "cube.GetComponent().Parent = gameObject", gameObject references the "player" GameObject, not the "hand" GameObject. This works, but the cube is centered on the player instead of the hand. On the other hand, if you do "cube.GetComponent().Parent = _hand" (_hand being a reference to the Hand GameObject) the soft parenting doesn't work at all since the Parent synced var never gets the value (it's "null" right after the assignment).
You're absolutely right, thank you. I use Soft Parenting for when there is no child object. However, this can still work - if you know that the Soft Parent will always have a child "hand" then inside the Update() of the held item, you can access that child object by name, type or whatever suits you. Apologies that this tutorial is out of date; I hope you found something of use.
@@RobLang Hey! Thanks for your kind answer :) I'm evaluating Mirror for my next project. I'm still struggling on how things work, what can and can't be done and struggling with unaccountable latency, even when all the processes are on the same machine. Also, it's still unclear to me when things need to run on "localPlayer", "allPlayers", "server", etc... a lot yet to learn. Thanks to your tutorials it's a little more pleasant :)
I have struggled with Mirror. My core concern is that Unity want setup well for multiplayer from the start. Mirror (and the official UNet that preceded it) was glued on after. Additionally, multiplayer is not suitable for "plug sand play" so adding components to make things work is only fine for a few scenarios. Mirror still has more features but MLAPI has official support, so that would be my choice of I were to start again. The bigger question is: does your game idea really need multiplayer? What personal need are you fulfilling by implementing it? If you get stuck, then upload a project to GitHub and send me a link either here or on Twitter (@brainwipe) and I'll take a look. I'm doing quite a lot of network traffic with Mirror and don't get lag. Also the Mirror discord is good too. Best of luck with your game!
@@RobLang I was going to implement a little prototype with Mirror and Photon to see the differences. If you recommend MLAPI (or "Netcode for GameObjects" as it seems it has been re-branded) I will give it a try as well.
There's a problem with this solution, because it allows objects that you're holding to enter walls. I tried to modify that, so that instead of parenting, an acceleration is added to an object towards desired location (also drag is added and gravity is off). Works great from host's perspective, but it's madness from client's perspective. I hope I can calibrate it somehow, because otherwise I need yet another solution. Maybe having invisible network object working your way and visible instance for client holding the object with the acceleration way... Anyway, great video!
Hello! Thank you, you're absolutely right. I ended up going with attaching a spring between the player and the object. Depending on your use case, you can then sync just transform or add rigidbody sync too (for the velocity). I use Soft Parenting in other places where collision is less of an issue. I need to make another video, apologies.
@@RobLang Thanks! It turned out, that setting the drag and turning the gravity off was only done on the server, so ClientRpc call did the trick. However, I really like your idea to use a spring and I'll probably try that eventually.
Interesting, this is the solution I had come up with before watching, however have you struggled with 'stuttering' of objects you have picked up when you start moving around? Could this have something to do with the computation not being fast enough to keep up with your hand in update? Unique looking game by the way, very cool. Subscribed!
Thank you! The stuttering is usually because the server and the client are calculating the position, when it should be only the client. Ensure that you're setting the ownership of the carried object to the player who has picked it up.
is there currently a new official solution to handle this problem? or did they even fix it in 2022? btw. thank you for showing us the possibilities. this is a huge limitation . this video helped me a lot.
Hello there! In Mirror, this is still the official way of doing it. Parenting is not possible. I've found more recently that Mirror's new features made it difficult to change ownership so I've been moving from Mirror to Unity's Netcode for Gameobjects. Here's why: ua-cam.com/video/tp5P7rG4SsI/v-deo.html
You're welcome! While I agree that the limitations are tough - all the frameworks are limited. I think the big difference between Mirror and NGO is the level of support. Mirror are volunteers doing their best. NGO is a corporation that wants the library for growth. NGO has limitations too (see my latest video) but Unity have responded on Discord gracefully and that matters a lot when you're up to your eyeballs in synchronisation bugs!
@@RobLang yeah thats true. but the support is also a really good point for NGO because without a proper support and community you would really get stuck at some bug.
3 роки тому+1
I was about to write that it's way easier for me to just copy the transform position and rotation instead seperating the artwork from everything else, and then you started talking about it. You have mind reading powers Rob. But I wonder, is this method more expensive than the traditional parenting method?
I do have mind reading powers... stop thinking that, you filthy man! As for expensive, I don't know for sure but I will do a performance pass once all the systems are synchronised and work out if I am sending too much data when I don't need to. Thanks for the support as always, Nermin!
3 роки тому+1
@@RobLang I swear I didn't think about that! Alright, may you update me when you test it? It seems like it could be to much data if you use it for every parent-child relation. That's probably why they came up with their own solution but you should be good using it just for picking up items. Keep up the good work!
@@RobLang This is my game and it is a board game in it, I move game objects with the mouse and I wanted to make it networked using Mirror, but it does not work. There are many videos where they only show the movement of the character through the Mirror, but nowhere does anyone show how to connect in the game and move the pieces like in checkers or chess (And that's why my game and I are stuck forever Could you help with this? I am ready to pay for your help!
@@lora6938 thank you for the offer of money; sadly I don't have time for paid work. I would solve this by doing drag and drop on the client and then when the piece is dropped, a Cmd is sent to the host/server with the move. The server then moves the piece and all the clients are updated either using a RPC or a network transform on the server. I hope that helps!
Hello, can you show how to pick up objects and release them using a mirror? I manage to take the item, but when releasing it, it is not released, and for clients it disappears at coordinates 0,0,0
Hi Lora, sorry for not getting back to you sooner. I'm not sure I understand why you're having this problem. If you're still struggling, please send me a DM on Discord with the code that performs the change and also the hierarchy. My Discord is: Rob Lang#7769
@@RobLang Ok, I will do it. And what is DM)😊? I'm actually trying to use a simple code that will make the item I pick up be my character's child and when I release the item it will go back into the hierarchy. Is this really the right way to do things like this? I just don't know any other way yet.
why make the objects a child of the hand when you could just have the object follow the hand while being its own object? would this not solve the problem you was having? btw your game looks like it has a lot of potential. Best of luck!
Still useful 3 years later. Was having problems with this EXACT problem and your way solved my issue instantly. Spent hours just for it to be a simple solution lmao
I'm delighted that this worked for you! I do wonder if there is a better way these days. I've not touched my pick up code recently, I'll have to give it a poke.
Thank you!
7:25 well, thank goodness I kept watching before commenting, because the entire time I was thinking "wouldn't it be much simpler to just set the cube's position/rotation as though it was a child of the player, without actually making it a child" 😂
Glad you figured it out and got it working!
Cheers mate! Yes, it is definitely the right decision. Especially when you consider in Clomper it's not just the players that pick up and drop stuff. 👍
God, your voice is really nice to listen to
Thank you! That's very kind of you to say so. 😊
Fantastic, exactly what I was looking for.
Splendid! If you get stuck further, please do check some of my other videos as I continued to hit other (connected) issues after this. 👍🏻
Thank you very much! You rock, literally two days working in until your video...
I'm glad I could help!
Really love the combination of devlog and tutorial you do! Very nice video :D
Thank you! I'll try and keep them coming. 🙂
Excellent explanations behind the official way and how you implemented it! Setting a parent like that is the kind of thing I'd do in my engine so I hope if I ever give networking a crack I can come up with a similar solution.
Good luck moving onto the gameplay for clomper.
Thank you! That's very kind of you to say. Multiplayer seems to add three times the work to any standard game. Best of luck!
Good Job Rob ! Mirror like to play the hard way ;D
Thank you! Why oh why can't just SOMETHING be easy? 😂
@@RobLang Haha yeah ! Everything is hard and takes time ;D
Yeah, it does. That's annoying! 😂
Great to see you fixed it in the end! The video was very well explained as well. I hope you can take a breather from all of the network stuff and do some fun gameplay stuff now!
I hope to do some fun stuff but it's not stable right now. I might just take break, thank you!
working on mirror currently myself... it's a lot ;) well done
Good luck with your project! Thank you. 👍
Great video on this, very easy to follow. I was running into the same issue and actually came up with a similar solution to your final solution. I hadn't thought and didn't know about the network wrapper though. Interesting idea, but I feel like the position and rotation matching is a bit easier personally. I did have some issues beyond that though. Whenever I picked up an item and then moved my character with the item being held, it would stutter as if it was a few frames behind and catching up. I changed the update that was setting the position and rotation to a LateUpdate and it seemed to fixed the issue.
I'm glad you found that useful and a solution to your jitter!
So glad that you got the networking issues more or less solved, I saw your tweet and you just seemed so defeated by it but I am glad you were able to defeat it! Also I don't understand networking in the slightest but your explanation of it in Clomper was perfect!
Thank you! I did feel defeated, to be honest. For a long time, I just want having fun. Rewriting the same 2 classes over and over. Thank you for the support!
@@RobLang I bet you weren't, but I'm so glad you got it sorted , and this solution seems pretty effective too! :D
Very interesting solution, I'm sure ill also have a lot of fun with Network issues as my next project will be multiplayer. BTW love the thumbnails.
Thank you for the thumbnail feedback. Great to know. If you need networking support, we can swear at it together if you like!
@@RobLang Thanks, I may just take you up on that.
So cool!
Thank you! 😊
So clear and exactly what i needed thank you
That's great to know, thank you for your feedback!
Quite enjoyed that troubleshooting, well explained! 😁👍 (Hope we never have to touch multiplayer networking 🤣)
Thank you! Put multiplayer in early. It's standard advice but it's right. Thank you for the feedback, I'm never really sure how to pitch the mid-level tutorial videos. Hope Micro-Snut is doing well and that the winter isn't too cold for you over there. :)
Damn networking seems like a hair puller glad your making more progress :D
It really is! Even more than the children. 😂
Thank you, Andrew! You're too kind. 😊
Question @RobLang, How did you make the pickup work with an offset? When picking up an object It assigns the softparent to the player character object, which works as expected, but when I try to pass in a child empty game object (hand) it does not work for clients. It assigns the hand to the softparent, but never moves.
I feel as if the answer would be simple and I'm being silly missing it.
Can you upload some code to somewhere and the images of your player prefab hierarchy so that I can have a look. Or send to my Discord DMs: Rob Lang#7769
Just wanted to say thank you! This helped me out and ended my trial and error headache. The documentation for network transform children isn't at all clear when it comes to carrying objects.
You're welcome, that's lovely to hear. This video is a bit old- I think there might be some good tweaks for another video.
Thanks for the explanation even though it doesn't work for me. Remember when you moved the hand.cs script from the hand to the player? This makes that when on hand.cs:28 you do "cube.GetComponent().Parent = gameObject", gameObject references the "player" GameObject, not the "hand" GameObject. This works, but the cube is centered on the player instead of the hand. On the other hand, if you do "cube.GetComponent().Parent = _hand" (_hand being a reference to the Hand GameObject) the soft parenting doesn't work at all since the Parent synced var never gets the value (it's "null" right after the assignment).
You're absolutely right, thank you. I use Soft Parenting for when there is no child object. However, this can still work - if you know that the Soft Parent will always have a child "hand" then inside the Update() of the held item, you can access that child object by name, type or whatever suits you.
Apologies that this tutorial is out of date; I hope you found something of use.
@@RobLang Hey! Thanks for your kind answer :) I'm evaluating Mirror for my next project. I'm still struggling on how things work, what can and can't be done and struggling with unaccountable latency, even when all the processes are on the same machine. Also, it's still unclear to me when things need to run on "localPlayer", "allPlayers", "server", etc... a lot yet to learn. Thanks to your tutorials it's a little more pleasant :)
I have struggled with Mirror. My core concern is that Unity want setup well for multiplayer from the start. Mirror (and the official UNet that preceded it) was glued on after. Additionally, multiplayer is not suitable for "plug sand play" so adding components to make things work is only fine for a few scenarios. Mirror still has more features but MLAPI has official support, so that would be my choice of I were to start again.
The bigger question is: does your game idea really need multiplayer? What personal need are you fulfilling by implementing it?
If you get stuck, then upload a project to GitHub and send me a link either here or on Twitter (@brainwipe) and I'll take a look. I'm doing quite a lot of network traffic with Mirror and don't get lag. Also the Mirror discord is good too.
Best of luck with your game!
@@RobLang I was going to implement a little prototype with Mirror and Photon to see the differences. If you recommend MLAPI (or "Netcode for GameObjects" as it seems it has been re-branded) I will give it a try as well.
There's a problem with this solution, because it allows objects that you're holding to enter walls. I tried to modify that, so that instead of parenting, an acceleration is added to an object towards desired location (also drag is added and gravity is off). Works great from host's perspective, but it's madness from client's perspective. I hope I can calibrate it somehow, because otherwise I need yet another solution. Maybe having invisible network object working your way and visible instance for client holding the object with the acceleration way... Anyway, great video!
Hello! Thank you, you're absolutely right. I ended up going with attaching a spring between the player and the object. Depending on your use case, you can then sync just transform or add rigidbody sync too (for the velocity). I use Soft Parenting in other places where collision is less of an issue. I need to make another video, apologies.
@@RobLang Thanks! It turned out, that setting the drag and turning the gravity off was only done on the server, so ClientRpc call did the trick. However, I really like your idea to use a spring and I'll probably try that eventually.
Interesting, this is the solution I had come up with before watching, however have you struggled with 'stuttering' of objects you have picked up when you start moving around? Could this have something to do with the computation not being fast enough to keep up with your hand in update?
Unique looking game by the way, very cool. Subscribed!
Thank you! The stuttering is usually because the server and the client are calculating the position, when it should be only the client. Ensure that you're setting the ownership of the carried object to the player who has picked it up.
is there currently a new official solution to handle this problem? or did they even fix it in 2022? btw. thank you for showing us the possibilities. this is a huge limitation . this video helped me a lot.
Hello there! In Mirror, this is still the official way of doing it. Parenting is not possible. I've found more recently that Mirror's new features made it difficult to change ownership so I've been moving from Mirror to Unity's Netcode for Gameobjects. Here's why: ua-cam.com/video/tp5P7rG4SsI/v-deo.html
@@RobLang Thank you for your quick response. i am going to watch the video. the limitations of mirror is really terrible.
You're welcome! While I agree that the limitations are tough - all the frameworks are limited. I think the big difference between Mirror and NGO is the level of support. Mirror are volunteers doing their best. NGO is a corporation that wants the library for growth. NGO has limitations too (see my latest video) but Unity have responded on Discord gracefully and that matters a lot when you're up to your eyeballs in synchronisation bugs!
@@RobLang yeah thats true. but the support is also a really good point for NGO because without a proper support and community you would really get stuck at some bug.
I was about to write that it's way easier for me to just copy the transform position and rotation instead seperating the artwork from everything else, and then you started talking about it. You have mind reading powers Rob.
But I wonder, is this method more expensive than the traditional parenting method?
I do have mind reading powers... stop thinking that, you filthy man! As for expensive, I don't know for sure but I will do a performance pass once all the systems are synchronised and work out if I am sending too much data when I don't need to. Thanks for the support as always, Nermin!
@@RobLang I swear I didn't think about that!
Alright, may you update me when you test it? It seems like it could be to much data if you use it for every parent-child relation. That's probably why they came up with their own solution but you should be good using it just for picking up items.
Keep up the good work!
Thanks mate, I'll keep you up to date.
Hello! You could show | Drag and Drop | * OnMouseDrag * with Mirror. Please !?
Hello! That's going to be tough to explain in a comment without lots of context. Do you have some code/example project I can see?
@@RobLang This is my game and it is a board game in it, I move game objects with the mouse and I wanted to make it networked using Mirror, but it does not work. There are many videos where they only show the movement of the character through the Mirror, but nowhere does anyone show how to connect in the game and move the pieces like in checkers or chess (And that's why my game and I are stuck forever
Could you help with this? I am ready to pay for your help!
@@lora6938 thank you for the offer of money; sadly I don't have time for paid work.
I would solve this by doing drag and drop on the client and then when the piece is dropped, a Cmd is sent to the host/server with the move. The server then moves the piece and all the clients are updated either using a RPC or a network transform on the server.
I hope that helps!
@@RobLang You are definitely a professor in this, but unfortunately I will not understand(
I just embarked on this network path
Hello, can you show how to pick up objects and release them using a mirror?
I manage to take the item, but when releasing it, it is not released, and for clients it disappears at coordinates 0,0,0
Hi Lora, sorry for not getting back to you sooner. I'm not sure I understand why you're having this problem. If you're still struggling, please send me a DM on Discord with the code that performs the change and also the hierarchy. My Discord is: Rob Lang#7769
@@RobLang Ok, I will do it. And what is DM)😊?
I'm actually trying to use a simple code that will make the item I pick up be my character's child and when I release the item it will go back into the hierarchy. Is this really the right way to do things like this? I just don't know any other way yet.
A DM is direct message that you can send in the free app called Discord. I hope that helps!
@@RobLang ☺️thank you!
I wonder if there are other alternatives to Mirror that support parenting. The solutions proposed seem a bit hacky to me.
The Unity chosen library uses MLAPI, which has the same issue (it's UNet). Photon didn't have that problem but I don't need the server cost.
why make the objects a child of the hand when you could just have the object follow the hand while being its own object? would this not solve the problem you was having? btw your game looks like it has a lot of potential. Best of luck!
Yes! That's essentially my third solution in the video. Thank you for the kind words, support and ideas! 👍😁
Can you please remove that annoying piano background, I can't understand the speech
Sorry you find it hard to hear. Perhaps it's a little loud on this one? I think the auto subtitles usually do a good job on my accent.