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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by william9518 · Aug 15, 2013 at 05:57 PM · parentchilddragparentinggun movement

Simulate 'Child' Effect by Script

OK so I am currently working on multiplayer of my game. I have added a multiplayer 'gun' and would like to set this prefab a child of the player parent WITHOUT ACTUALLY SETTING IT AS A PARENT. So what I'd need to do is somehow 'simulate' the child-parent relationship without setting the parent. I've tried setting the position & eulerAngles to the parent counterpart, but of course the child-parent relationship is way more complicated. For instance, in my script where I just set the position & eulerAngles = the parent, the position will move with the parent and so does the rotation, but since my weapon 'sticks' out a bit, the rotation is messed up. It is hard to explain, but I will provide a few images for the sake of explanation.

So here is an image of before turning with the parent-child simulation, the smaller gun is the example here. The larger weapon with the arms are just there for a reference.

alt text

Here is an image of after I turn slightly to the right:

alt text

So as you can see, the weapon turns accordingly to its parent, but it doesn't REALLY simulate the parent-child relation. Any help is appreciated.

Thanks in advance, william9518

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 william9518 · Aug 15, 2013 at 08:03 PM 0
Share

Anyone help?

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by william9518 · Aug 31, 2013 at 12:41 AM

Ugh I fixed it by not doing it at all and revamping the whole system.

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 Joyrider · Aug 15, 2013 at 08:13 PM

you could create a dummy that has everything the same as the fake parent, and make your gun a child of that one...

This should make your gun behave just as if it was the fakeParent's child. His local space would be identical than if he really was a child of that object. And modification of the parent would have the same effect as the fakeParent would have.

Don't know if that would be an option for you?

Comment
Add comment · Show 7 · 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 william9518 · Aug 15, 2013 at 08:53 PM 0
Share

No I cannot use it as an option. I CANNOT set a parent for the gun, I can only use some substitute that may simulate it. Thanks anyway.

avatar image Joyrider · Aug 15, 2013 at 09:31 PM 0
Share

Well, maybe you can take it the other way around. Create a dummy child (not child of the gun, but of your want-to-be gun parent) that has the usual position of the gun, and have that child assigns it's parameters to the gun.

avatar image william9518 · Aug 16, 2013 at 12:09 AM 0
Share

Doesn't work. Is there not a way to simulate being a child?

avatar image Joyrider · Aug 16, 2013 at 12:21 AM 0
Share

How do you mean.. it doesn't work? what did you do? and what does not work?

And sure, you can simulate... Let's say your it-can't-be-my-gun's-parent is your character. if you know how your gun's local matrix would be like if it was the character's child, you can multiply that character's $$anonymous$$atrix with the local matrix you'd want. Plus some functions allow you to indicate according to what reference you want to apply your movement. So moving your gun with your character as a reference shouldn't be a problem. Having your gun move according to your character's movement can sometimes be a little more tricky.

But 3D is all about math, so you just have to get a little bit more into it.

avatar image william9518 · Aug 16, 2013 at 12:27 AM 0
Share

By 'it doesn't work', I mean I'm doing this in multiplayer. I only set the gun in local, and display it in multiplayer. So only for myself will the dummy parenting work, but for other people it won't. So what I mean is I CANNOT set any parenting for a network, but I can use the networkView for position updating. So any dummy or ANY solution that requires parenting will not work. And about the math, could you tell me more? :3

Show more comments

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

16 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

Related Questions

Make a simple tree 1 Answer

Parent object to child of another? 1 Answer

Why is the order of parent and child different depending on where you select them? 1 Answer

Parenting Transforms, Must (still) Set Parent at 0,0,0 ? 1 Answer

Can I add a parent to all the children in an animation tree structure ? 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