Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 FesterTY · Mar 07, 2019 at 04:23 PM · collisionphysicsvelocityboxcollider

I want collision boxes to be precise without overlapping each other

alt text

I want the player's movement to be very precious, but without collision boxes overlapping each other. Because with overlapping, the player wouldn't be able to move forward (I have set it so that player has a velocity of 0 if they ever hit a collision box). Keep in mind, my player moves like how tiles in 2048 (game) works. Any advice are appreciated. Thanks in advance! :)

capture.png (15.3 kB)
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 TreyH · Mar 07, 2019 at 04:34 PM 0
Share

Can you go into a little more detail? Hard to understand what you're even asking.

avatar image FesterTY TreyH · Mar 07, 2019 at 04:48 PM 0
Share

Hi there! So basically, both the player and the block has a collision box with a scale of 1. Their sizes are both 1 unit. However, when I play, they "overlap" each other, making the player unable to move to the desired position. Looking at the picture, the collision box is preventing the player from moving to the right. I want to be able to scale the collision box down to 0.8, but then the player (which moves like a tile from 2048), will have their body stuck into one of the block, and that's not ideal.

1 Reply

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

Answer by Major · Mar 07, 2019 at 10:54 PM

You aren't going to get that level of precision with the physics engine as is. There has to be some level of overlap (however small) because of the way collision detection and collision response is handled. Furthermore, relying on floating point numbers with distances that small is not a great idea, as you will probably get some precision issues anyways.


However, if your player is supposed to move in a fashion very similar to 2048 tiles, then you don't need to use the physics engine in the first place. In fact, it would be over kill to do so. You would be better off storing your level data in a 2D array of, say integers where the value at some position in the array tells you what kind of tile is at the position. When you want to move the player, you can check for tiles that are impenetrable in the direction of travel. If a tile exists that the player should not be able to move through, then you do the entirely obvious thing of... don't move them.


With that being said, you would also need to store the player position as a pair of integers so that you can quickly index the level tile data to check for potential collisions.


Obviously this is more work than just dropping sprites into the scene, but it will get you the level of precision you want in your moment system, and separate you from Unity's physics engine and allow you to implement your own behaviors.

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 FesterTY · Mar 08, 2019 at 06:07 AM 0
Share

Sorry for the late reply, but thank you for the advice! Appreciate it!

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

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

BoxCollider get stuck when dragging over the border of two BoxColliders 1 Answer

(Steam VR / Vive) Rigidbody moving in only one direction after collision 1 Answer

Why is the relativeVelocity of a Collision always zero in OnCollisionEnter and OnCollisionStay? 0 Answers

Big issue with colliders 1 Answer

Resume movement of instanced object relative to the original after instantiation. 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