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 IvanHTN · Jun 22, 2016 at 05:14 AM · physicscollider3d

[3D] Character stuck between cubes.

My character get's stuck between cubes (that i use as platforms) when walking, just at the edge between them and the both cubes are side by side with no space in between.

My character has a rigidbody with freezed rotation axis.

I tried box collider, sphere collider, capsule collider... none of them seems to be the problem. I also tried adding a sphere colliders at the bottom of the box collider but nothing.

Cubes are box colliders with scale of (20, 1, 20).

EDIT - Here is a screenshot, there are the two cubes side by side and the capsule collider stuck between them: alt text

EDIT2 - Rigidbody

alt text

Edit3 - Movement Script:

 Vector3 dir = movementJoystick.inputDirection;
 Vector3 forward = mainCamera.transform.TransformDirection (Vector3.forward);
 forward.y = 0;
 forward = forward.normalized;
 Vector3 right = new Vector3 (forward.z, 0, -forward.x);
 float h = dir.x;
 float v = dir.z;
 dir = h * right + v * forward;
 body.position += dir * (Time.deltaTime * walkSpeed);

SOLVED: It had to do with OnCollisionEnter and OnCollisionExit. I was using a bool of grounded to know if the character was or not. Seems traspassing the edge of the collider called the function making grounded go false.

Then i have specified that if my character is not grounded he won't be able to move. So that whas the problem.

So from now on i will use raycasting. Thanks to everyone that helped me!

problem.png (4.7 kB)
problem2.png (9.1 kB)
Comment
Add comment · Show 6
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 IvovdMarel · Jun 22, 2016 at 05:17 AM 0
Share

The capsule collider should work just fine. Are you sure you didn't accidentally freeze the y-axis?

avatar image IvanHTN · Jun 22, 2016 at 08:08 AM 0
Share

X, Y, Z rotation axis are freezed but not movement ones.

I tried playing with them and the result is the same. Capsule collider gets stuck between two cube colliders. I even have the character floating at the start to ensure he isn't under the surface.

avatar image EpiFouloux · Jun 22, 2016 at 11:58 AM 0
Share

can we have a screenshot of your rigidbody component? and your movement script?

avatar image IvanHTN · Jun 22, 2016 at 12:21 PM 0
Share

$$anonymous$$ore info added.

avatar image IvanHTN · Jun 22, 2016 at 06:17 PM 0
Share

Here is the problem, the character traspasses the edge but gets stuck there in between: alt text

problem.png (25.0 kB)
Show more comments

3 Replies

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

Answer by IvanHTN · Jun 22, 2016 at 09:26 PM

Okey i feel ashamed, it had to be with my grounded collision script.

On leaving a collider it declared grounded as false and i have defined that something that is not grounded can't move at all.

So when the character was reaching the edge of the first cube it goes directly to grounded = false and then is unable to recognize fast enough the second cube for getting the grounded = true.

Comment
Add comment · 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
0

Answer by seckincengiz · Jun 22, 2016 at 02:42 PM

Try using one big box collider for both cubes. Sometimes(if your object too small) unity can't response fast enough to detect collision. You can also change that response time( time settings / Fixed Timestep). Also change your rigidbody component's Collision Detection as Continuous Dynamic. And make sure your collider component's "Is Trigger" option unchecked. If problem still exist check your physics settings (Layer Collision Matrix). These are the basic rules that you should look first when your colliders act weird. But in your case you should also check your script again. Disable the script and try again. Your script could be the problem.

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 IvanHTN · Jun 22, 2016 at 04:06 PM 0
Share

Using 1 collider solves the problem but i discovered that this also happens when i go to a corner of walls, character get's stuck between colliders.

I checked everything else u mention except the Layer Collision $$anonymous$$atrix which is something i don't understand, here is my configuration: Is there something wrong?

alt text

I'm going to check if there is something wrong with my script.

problem3.png (17.9 kB)
avatar image seckincengiz IvanHTN · Jun 22, 2016 at 05:17 PM 0
Share

It looks like your collision matrix (http://docs.unity3d.com/$$anonymous$$anual/LayerBasedCollision.html) is not the problem here. Did you try unfreeze rotations? $$anonymous$$aybe the force which is trying to rotate your object is also push it because of your object's fixed rotations.

You said that one big collider solved your problem. It means that your script may not the problem. Try to scale size of your collider. For example (20,1,20) --> (20,10,20)

if it doesn't work try to apply your script another collider and try again. $$anonymous$$aybe you changed something on that object and you don't remember.

avatar image
0

Answer by TCROC · Jun 22, 2016 at 04:06 PM

Have you tried making your collision detection continuous or continuous dynamic? It is normally used for detection collisions between fast moving objects like bullets, but it could do the trick for you.

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 IvanHTN · Jun 22, 2016 at 04:31 PM 0
Share

Already tried, nothing. It seems it's something related to my script, trying to find out what it is.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycast and colliders problem. Corners of two colliders 0 Answers

Physics - strange jumps. 2 Answers

Cant fix my collider problem on an object, help me up :) 1 Answer

Objects stops if it lands in between two colliders 1 Answer

Why Do My Capsule Colliders Move When Hit? 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