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 Emirk · Apr 02, 2014 at 04:31 PM · collider 2drigidbody 2d

Moving static colliders in Unity 2D

There's a lot of warnings about moving static colliders, but I'm a bit confused about static colliders in 2D.

I have an infinite runner game where the ground is spawned when the player moves. To avoid lots of Destroy and Instantiate calls I'm using a pooling system. The ground consists of groundblock gameobjects that simply have a box collider attached. No rigidbody. When the player moves forward, I'm effectively moving blocks from behind the player to infront of him. Hence, I'm moving static colliders - a big no-no. How do I remedy this? The approach in 3D would be to attach a rigidbody to my groundblocks, check isKinematic and change groundblock.rigidbody.position, which is a lot faster than groundblock.transform.position on a static collider. However, the Rigidbody2D doesn't have a position member, nor does it have a movePosition method.

What's the approach here?

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 Gruffy · Apr 02, 2014 at 04:47 PM 0
Share

hey bud, With rigidbody you either .AddForce(); or .$$anonymous$$ovePosition(); etc here is a link to rigidbody on the docs pages This will help you immensely, plus you are only ever adding a rigidbody to a gameObject as a component, so invariably, you will have access to the rigidbodies position member as it is the same as its parent holding Object (GameObject), which has transform to access its positional data.

1 Reply

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

Answer by CatchCo · Apr 02, 2014 at 04:46 PM

If the rigidbody is Kinematic you can just change Transform.position. If you scroll all the way to the bottom of the Rigidbody Component Documentation page you will find this line:

If you are directly manipulating the Transform component of your object but still want physics, attach a Rigidbody and make it Kinematic.

Essentially, Kinematic means that it's movements will not be governed by the physics system but it will still interact with physics objects.

Comment
Add comment · Show 2 · 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 liortal · Jun 22, 2014 at 09:34 AM 0
Share

Is there any explanation on why this is needed? I suppose the extra component overhead would still execute better than without it ?

avatar image unimechanic ♦♦ · Sep 30, 2014 at 04:32 PM 1
Share

@liortal please read the Static Colliders section that explains this with more details:

http://docs.unity3d.com/430/Documentation/Components/DynamicsGroupOverview.html

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I make 2d sprites for Unity ? 1 Answer

code your own colision system i unity 0 Answers

Disable 2D Phsysics 2 Answers

(2D) Creating a border around the game 4 Answers

Unity 2D: sprite's rigidbody weight/rotation 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