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 StephanT · Mar 15, 2015 at 07:41 PM · rigidbodyscaletreesrigidbody physicsrigidbody collision

How to scale up a rigidbody without moving it?

Hi everyone,

I'm working on a game similar to Settlers 2 / 3, but with free 3D graphics and more physics realism. Currently, I'm trying to get the forester and lumberjack done. The forester plants trees, which grow, and get chopped when fully grown by the lumberjack for wood.

My question is about growing trees. For simplicity, a "tree" is currently represented by a simple cylinder, which can grow in size and change color. Each tree has a rigidbody to enable physical interaction. For example, when chopped down, a falling tree may carry down other trees in the process.

I'm experiencing big problems with those bodies when their scale is increased to make them grow. They start moving on their own, pop out of the ground (even when placed directly above it), break hinges which should hold them in place and so on. I think the problem is that I'm constantly modifying a rigidbody using scale and position to make it grow and stay in place. I know that rigidbodies should be treated with forces only to avoid weird effects.

I've searched for solutions for days, but didn't find any. I thought about not modifying the rigidbodies at all but adding more and more to simulate growth, but this approach has problems, too.

Is there any way to grow a rigidbody in size which is resting on a surface in place?

These are the two lines of code which I currently use to make the "trees" (primitive cylinders) grow:

 transform.localScale *= GrowthSpeed;
 transform.position = new Vector3 (transform.position.x, transform.localScale.y, transform.position.z);

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
2

Answer by LeftRight92 · Mar 15, 2015 at 09:28 PM

I haven't got a huge experience working with rigidbodies, but the first thing that springs to mind is that you could add the rigidbody once the tree is being cut down (and will therefore start falling over).

As you only need 1 rigidbody between two objects colliding for the collision to be registered, you could simply then create rigidbodies on other trees that the first tree collides with within OnCollisionEnter (and recurse naturally).

Not much of an answer, but I hope this helps.

Comment
Add comment · Show 1 · 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 StephanT · Mar 16, 2015 at 10:23 PM 0
Share

Thank you, LeftRight92! It wasn't what I was looking for, but you inspired me to a workaround, which I'll use for the time being.

Now, I'm planting fully-grown "trees" (selfmade, not the existing Unity-Trees), adding rigidbodies a few seconds after the forester has left to avoid weird collisions.

If anyone has an idea how to make rigidbodies grow in size without causing weird collisions, I'm still looking for it.

Shrinking them works fine ... once chopped down my rooftops start "decaying" (by shrinking).

avatar image
0

Answer by Pendantic · Mar 16, 2015 at 10:48 PM

First make the uncut trees rigidbody Kinematic, this make it not respond to physics, then when you cut it down change to isKinematic to false

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Plane CollisionWheels keep jumping around 0 Answers

Player can't interact certain Rigid Body while another rigid body can. 0 Answers

How can i make my RigidBodyFPSController to move when Is Kinematic is true ? 1 Answer

Can you have an OnTriggerX event with Sleeping rigidbodies? 1 Answer

Mass place trees scale issue 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