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 htaunay · Sep 03, 2014 at 01:01 PM · collisionmovementcollidermove an object

Movement with collision detection but without a CharacterController

How can I move a scene object A, that contains a Collider component as well as a RigidBody, in order that if such object A is blocked by another static object B, that also contains a Collider component, object A's translation will be limited to object B's bounds? All of this WITHOUT using a CharacterController or RigidBody.AddForce.

To be move specific: I am only interested in limiting specific movements. Gravity, rotation, slope limits, inertia, all of these can be disconsidered. I originally was working just by updating the object A transform's position and manually checking the scene's bounds (sometimes with the help of OnTriggerEnter, sometimes with a custom solution), but the workload has become overwhelming.

Any suggestions? Am I going at it the wrong way? Thanks in advance.

Comment
Add comment · Show 2
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 corriedotdev · Sep 03, 2014 at 01:14 PM 0
Share

So if A hits B, A can only move in object B's bounds?

avatar image htaunay · Sep 03, 2014 at 01:19 PM 0
Share

If A receives a $$anonymous$$ove input of Vec3(5,0,0), and B is at an exact distance (diff) of Vec3(2,0,0), A should only be allowed to move Vec3(3,0,0). In the case of the same input again, A would not move at all. B in no case moves or should be affected by the collision.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Andrew_Kenady · Sep 03, 2014 at 01:24 PM

I'm a bit confused by your question. The way I've interpreted what you've asked is "how can I preserve collision while not using a character controller or rigidbody forces?".

If this is the case, all you need to do is update your object's transform.position at runtime. As long as both objects have colliders and rigidbodies, physics will still act upon them and prevent them from occupying the same space.

So, for instance, let's say object 1 is a sphere and object 2 is a wall (cube). You can give both objects a collider (sphere and box, respectively) and a rigidbody. You could choose to make your wall's rigidbody kinematic, so as to freeze it in world space. Then you might choose to freeze your sphere's rigidbody x, y, and z rotation (depending on the application).

Then, all you would need to do is update your sphere's transform.position from code, and the colliders should work as expected when the sphere reaches the wall.

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 htaunay · Sep 03, 2014 at 01:30 PM 0
Share

Thanks Andrew. This was my original strategy but I recall the "physics will still act upon them and prevent them from occupying the same space" premise failing. Later when I get the opportunity to put my hands on the project again I will give it a double-check, and afterwards some feedback.

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

24 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

Related Questions

player collite with object and start moonwalking 1 Answer

Multiple Colliders malfunctioning 0 Answers

How having correct bounce on a rotating pinwheel(it's more complicated)? 0 Answers

Collision Issue - Walk Through Object 0 Answers

can not move my enemy with rigidbody 1 Answer


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