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 U2-84 · Nov 06, 2012 at 07:11 PM · rigidbodycollidersweightheavy

Rigidbody and colliders, "weight" problem

Hello, I'll quickly describe my problem: the spaceship is a rigidbody in a box collider. When I apply a collider, the ship becomes "heavier" (I don't know if it's normal, but I accept it). I added a script that enable a "shield" around the ship when a key is pressed, so the ship doesn't receive damage when it is active. The shield has a collider, obviously, and it's instantiated as child of the "shield generator" (an empty object, child of the ship).

When I activate the shield, the ship gets heavier for the same reason written above, but the weird thing is that when the shield goes away (it lasts X seconds), the ship stays heavy. At first I tought the collider of the shield was still attached to my ship, but I tested it just colliding against an object and I'm sure there's no collider.. So, why my ship is still that heavy?

This problem is driving me crazy, I can't figure out how to fix it.

Thanks in advance ;)

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

2 Replies

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

Answer by sparkzbarca · Nov 06, 2012 at 11:30 PM

the collider is still attached unless you destroyed it after use and it should have existed before you pressed the shield button.

I'm not sure how your doing this collider generation but the way you should be doing it is disabling and enabling the collider.

Destroying and spawning the collider is more intensive. the collider should always be there and just be "on" or "off".

Once you have the colliders always there the weight will be constant, as expected and you can simply adjust your propulsion to look correct.

Comment
Add comment · Show 6 · 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 U2-84 · Nov 07, 2012 at 12:35 AM 0
Share

Here's my collider "creation":

  • I have a Shield prefab (not related to my ship.. it's a shield for every ship in the game). The Shield is a textured sphere with a sphere collider;

  • There's a "Ship Generator" object (an empty game object) as child in every ship, with a script attached (the script allows me -or the enemy- to instantiate the shield and automatically make it a child of the Shield Generator with the line clonedshield.transform.parent=transform);

  • When I press a key, I instantiate a copy of the shield (so the shield and its collider) around my ship. The ship gets heavier and it's quite normal (1 more collider attached);

  • The Shield has a timer: after 5 seconds it disappears (Destroy(clonedshield.gameObject, 5.0)). But here's the problem: after it goes off, the ship remains heavy! And I really don't know why. Correct me if I'm wrong: when you call the Destroy function, you destroy both the game object and its collider. So, why the ship remains heavy like there's the shield collider still attached?

avatar image sparkzbarca · Nov 07, 2012 at 01:01 AM 0
Share

well i'm still going with you shouldnt be starting out with the collider not on. and you shouldnt be destroying the collider.

START WITH THE shield on the ship it should always be on. but disable collisions. thats done with

gameobject.collider.enable = false; gameobject.renderer.enabled = false; //makes the object invisible

then after 5 seconds gameobject.collider.enable = true; gameobject.renderer.enabled = true;

i'm confused about this weight thing. the number of colliders has nothing to do with mass (as far as i know) only the number of rigidbodies. well I mean ideally you should only have 1 rigidbody with 1 mass.

does the Shield prefab include a rigidbody?

avatar image U2-84 · Nov 07, 2012 at 01:15 AM 0
Share

No, the Shield is just a sphere with a collider. No rigidbody. I don't know why the collider affects the handling of the ship, to be honest. I'm going to try your option now ;)

If someone knows why the collider acts like that..feel free to tell something :)

avatar image U2-84 · Nov 07, 2012 at 01:44 AM 0
Share

Just a quick comment to let you know it worked great ;)

avatar image sparkzbarca · Nov 07, 2012 at 03:17 AM 0
Share

yay!

I hope the mass stays constant now.

Show more comments
avatar image
0

Answer by ProbePLayer · Oct 06, 2013 at 02:02 AM

I think I have a similar problem: I add a box as a child to this object with a rigidbody, and it suddenly shifts to the side where the box is, as if the center of mass has been changed. So maybe colliders don't have a mass, but they are included in how the center of mass is calculated. Right?

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

11 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

Related Questions

Rigidbody bumps slightly where ground colliders meet 1 Answer

Navmeshagents, Character Controllers and Colliders 1 Answer

Wheelcolliders stuck in ground 0 Answers

Avoid Rigidbody Intersection 1 Answer

Can i Move/Rotate triggers without Rigidbodies? And other collider questions. 3 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