• 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
Question by kodishfish · Oct 09, 2022 at 11:07 PM · rigidbody2dparent-childtransform.translate

can i use translate on parent of an object with rigidbody?

ok so. in my game i have a "player" empty game object. "player" has a c$$anonymous$$ld called "sprite", just for animating, and another c$$anonymous$$ld called "shadow", because the player's shadow is relevant in t$$anonymous$$s game. "shadow" has a rigidbody2d because i need to use OnCollisionEnter to check if it's touc$$anonymous$$ng some other gameobjects.
i need the player to be able to move themselves by controlling the parent object. i know that you shouldn't use transform.Translate() on an object with a rigidbody, so is it okay to use Translate to move the parent of a c$$anonymous$$ld with a rigidbody? t$$anonymous$$s is a 2d game, so i don't really want to add a rigidbody to the parent and have to deal with forces and mass and drag and everyt$$anonymous$$ng.

Comment
SurreyMuso

People who like this

1 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 SurreyMuso · Oct 10, 2022 at 08:57 AM 0
Share

I'm voting up this question because it's a really good one. Very interesting use case...

It strikes me that the "player" is actually your shadow and the sprite is just a visual artefact of your player and so the sprite should be a child of the shadow. Might that help? It would mean putting your script on the shadow, not the empty game object and moving the shadow using RigidBody.MovePositon but that shouldn't be a hardship. Set Gravity Scale, Drag and Angular Drag to 0.

Then again, can the sprite pass through walls and other game objects? You would need physics as well to prevent it doing so. In any case, if you have a composite game object with multiple rigid bodies, you may need to use joints to keep them together. I know that adds another layer of complexity but, unless you have a single game object comprising body and shadow together with a polygon collider you risk shadow and sprite separating.

Still thinking about this one. First time I've come across this idea. Nice one...

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

148 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 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 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 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 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 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 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

Does Transform.Translate override Rigibody2D.MovePosition? 0 Answers

Problem with a RigidBody and IsKinematic... I think 1 Answer

GameObject won't move with transform.translate or rigidbody2d.moveposition,GameObject won't move in void Start() 1 Answer

How to rotate a rigidbody relative to another? 1 Answer

I can't smooth the continuous movement of my Kinematic Rigidbody2D 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