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 /
avatar image
0
Question by Ashsaber · Feb 03, 2015 at 12:33 AM · c#physicstransformforce

Empty GameObjects fly away.

As the title implies, I'm having a bit of a situation. I have a character prefab with some child objects that are empty managers for more child objects.

I move my character by adding force to it.

There are issues where if my character moves (at all) it will "throw" its empty child objects all over the place (which makes it hard to use them as managers since they're now 50 miles from my character).

I'm not entirely sure why, though I'm guessing that it's because of the whole "moving by force" business, since the empty GameObject goes so much farther than the parent.

So my question is:

Is the problem of empty GameObjects flying all over the place a result of adding force to the master parent? And if it is, what should I do to stop it from happening?

I'm guessing I need to zero the forces on the GameObjects but I'm having a hard time wrapping my mind around this.

(To give you an idea, this is how my character moves)

 rigidbody.velocity = transform.forward * animatedMoveSpeed;
         rigidbody.AddForce(0, animatedAltitudeSpeed, 0, ForceMode.Impulse);
         rigidbody.AddTorque(0, Mathf.Deg2Rad * animatedTurnSpeed, 0, ForceMode.Impulse);
 
         SpeedClamp ();


Revision 1- The manager game objects just have a transform and a script.

Comment
Add comment · Show 2
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 HYPERSAVV · Feb 03, 2015 at 12:42 AM 0
Share

Do these empty GOs contain rigidbody components? Consider making them kinetic (or just remove them) if they do.

avatar image Ashsaber · Feb 03, 2015 at 12:59 AM 0
Share

No rigidbodies, just a transform and a script.

I tried adding a rigidbody (without colliders) just to see how it went and it behaved exactly the same as it was before, which is why I'm inclined to call it an issue of force.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by carrollh · Feb 03, 2015 at 12:51 AM

It sounds like your "empty game objects" have rigidbodies. Which are colliding with your character's and being blasted all over. Try making the ones you don't want moving around kinetic (check box) or just remove them all together and use a collider for interactivity if you don't need to physically push them. Or you could add them to their own layer and add the character to another and then tell the Physics engine to ignore collisions between those specific layers. Physics.IgnoreLayerCollision

Comment
Add comment · Show 4 · 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 Ashsaber · Feb 03, 2015 at 12:58 AM 0
Share

Unfortunately, they do not. They have their transform and one script (that acts as the managing script). As far as I know they're not doing any kind of colliding, since one of the managers is placed in front of the character, and after turning it goes...well, more "in front".

avatar image carrollh · Feb 03, 2015 at 10:52 PM 0
Share

Well, if nothing else you could always put a script on the empties that updates their local position and rotation every update cycle. And by "updates" I mean puts it back in place with transform.position = the Vector3 position of something like an attachment point on your character.

avatar image Ashsaber · Feb 04, 2015 at 01:00 AM 0
Share

Tried that, but nothing going, although I may have found the problem. I was assigning their localposition to be the same as the parent position (which meant they were, say, 110 units away from the parent because the parent was at 110).

avatar image Ashsaber · Feb 04, 2015 at 01:04 AM 0
Share

Ok, confirmed. I durdled with their assignment code.

avatar image
0

Answer by Ashsaber · Feb 04, 2015 at 05:24 AM

False alarm, false alarm; I had assigned their localPosition to be the same as their parent, so as a result the little floating weapons thought they needed to be in a vastly different position from where they really were supposed to be.

All fixed now. :D

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to apply in opposite direction to transform? 1 Answer

Rotating child doesn't move parent Rigidbody? 1 Answer

How to use an axis of a eulerAngle for a targetAngle on a HingeJoint? [C#] 0 Answers

Parenting not working with massive force to rigidbody. Does having rigidbody on child screw things up? 1 Answer

Get result (force & torque) of AddForceAtPosition? 2 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