Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Scaling in runtime with rigidbody

Discussion in 'Scripting' started by Alienchild, Aug 31, 2011.

  1. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    Hi

    I would like to prototype a game mechanic where two bodies colliding will merge into one. I plan to achieve this through simply scaling one of the objects and destroying the other. However since I have a rigidbody attached I cannot move the objects around using the transform without messing up the collision. I guess this would also mean I cannot use transform.localScale?

    Thanks in advance for any help!
     
  2. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    I've done some tests with localScale and it works. I've been adviced on the IRC channel before though stay away from the transform when having a rigidbody that is not set to kinematic, so would be great if someone can confirm that this won't break anything and create weird behavior further down the line in development :)
     
  3. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I've worked with dynamically scaling rigidbodies before. It won't break anything. You just need to know what you're doing.