My 2D character floating when animation starts, the collider is correct and Physics 2D too. How I solve this problem?
Edit Mode
Floating during animation
Idle Animation
Walk Animation
On your screenshots, I don't see the collider moving: transform of your Player and the offset/size of the collider don't change.
It's more probably a problem with your sprite directly.
Maybe take a look at the Sprite editor and check were are pivot points.
Related
After coding left and right movement of player which had BoxCollider and Rigidbody, An serious problem happened. when player moved toward an cube which had BoxCollider, player's collider overlapped with the cube by 0.02. Please tell me how to fix this problem.
For your information, the movement that I made was by rigidbody.MovePosition in FixedUpdate. And I already set collision detection to continuous. Also, I set the friction to zero with Physics Material.
When player don't move, the x Position is 2.525 enter image description here
But when player move, the x Position is 2.545 enter image description here
Colliders overlap - it's how collision detection works. If the overlap is too great, you can make one or both of them bigger, make the physics settings tighter, or some combination of these. Note that the amount of overlap is also affected by the speed of the objects - the more speed, the more potential overlap. What you can't do is expect PhysX to work with no collider overlap.
I'm using a terrain in Unity 2019.2.1f1 and a custom mesh of a cave with a mesh collider.
My character that has a Capsule Collider way bigger than the entry of the cave should not be able to enter in. But due to the roundness of both colliders, he can come into force in the cave, glitching through the terrain collider.
I think it's velocity is not excessive, I'm moving the character with rb.MovePosition() in the FixedUpdate(), and I set its rigidbody collision detection to Continuous speculative (tried all the "continuous" modes)
In the animation below, you can see the mesh of the cave and the capsule collider around the character.
How can I prevent this from happening? How can I say to Unity: "I want the colliders to be rock solid and not marshmallow"?
Colliders in Unity are rock-solid. They are incapable of any kind of soft physics, and the only moment they will warp through each other is when you force them to.
Here, you are setting the rigidBody position by force, into an impossible location. The game tries its best to fit your rigidBody despite the lack of room.
You can
Only use forces, and velocities. You can simply set the velocity to the direction of your choosing, and set it to 0 when you stop moving, or use AddForce, which is basically the same thing.
Keep using MovePosition, but use a SphereCast or CapsuleCast to check if you have enough room to move first.
I work on a game in which you can build your own level and play it. You can create a cube, with a box collider, and move it where you wants. You can also change its color. But when you put two cube next to the other, the character will detect a collision on Z axis. As my character collider is a capsule, it make my character jump. If I put a box collider instead of capsule, my character is stopped.
Here is a explanatory video: https://youtu.be/xuqs1zcdDlk
I tried to overlap both colliders, but problem is still here. Colliders have exactly the same height. How should I solve this??
Go to Edit > Project Settings > Physics, and try your game changing the Default Contact Offset value untill 0.
Good luck for your game, can't wait to play it !
I have some issues using CapsuleCollider and RigidBodyController in a Player GameObject in Unity.
Using a CapsuleCollider as collider for the player, I noticed that the player doesn't move like a capsule or a sphere (in other words, I want that the movement should be like a rolling ball, with no stuttering), but its movements like more like a box pushed, with stops and starts, that make some little oscillations of the camera.
Any ideas, solutions or tips?
realy that is all based on how your moving the object, and the rigidbody2D settings of the object, I think using physics forces would roll your character like a ball or capsule, however just setting a velocity wont.
I have a ramp and I move a sphere with arrows. I have unity's gravity and I want the rigid body of sphere to slide when it is stoped at the top of the ramp but without rotating it's body. The problem is if I Freeze rotation on x axis, it won't slide.
Try to use physics materials like ice and freeze rotations.
See info about materials here. "Like ice" means than you need set frictions to zero.
You should create a new Physical Material and set both dynamic and static friction to 0. Then drag it to the sphere and maybe also to the ramp.
Test with both rotation constrained and not.