I'm having a simple cube which is my character that can jump on a moving quad (left to right vise-versa) having a collider with friction physics material.The issue i'm facing is when the character jumps on the moving quad, instead of carrying the character along with the quad it leaves the character, friction didn't happen between quad and character in order to carry the character.I tried playing around with physics settings and also tried with a cube instead of a quad.
Im tweeting the quad for animation(Dotween),character has collider (friction material),rigid-body (angular drag - 0.05,drag - 0)
Screenshot of my character and quads
My Issue of quad moving without character
I don't understand this should be taken care of unity's physics engine.we shouldn't be configuring unnecessarily or am i missing something?
Related
Have Mesh Colliders on everything except the Solider being a child of the Game Object renamed Player.
The Player has a Character Contoller surrounding the child or blue-colored soldier. In Game Play, he falls halfway through the road and gets stuck in Unity. Is there a fix for this????
I noticed the Unity forum had not answered a similar question about it since 2019.
Colliders
Make sure that the actual model / mesh of your character has a mesh collider applied to it and that the convex box is checked. Next make sure that your ground / whatever your character lands on has a collider attached to it whether this collider is of type mesh, box or really any collider it shouldn't matter but I'd recommend trying a cube with a box collider first. Also make sure that all of your mesh colliders actually have a mesh applied to them.
For your character controller double check that the size of it matches your characters model in both width and height. Apply the actual Character Controller to the Parent game object in your case named Player and apply the mesh collider to your actual character.
Some Images of how it should look when correctly set up
How the parent "Player" should be set up simply
How the actual character should be set up simply
How your ground should be set up simply
This bug occurs very rarely (probably 1 in 100 collisions with a platform) where the players box collider 2d have contacts with the platform horizontally (two contacts with (-1,0) vectors and two (intented) with(0,1)). This is very problematic because the player cannot jump forward (just jumps up without any x velocity) and it looks like it hits an invisible wall. I tried increasing the default contact offset in the physics 2D settings to 0.01 but it did not help. I am creating a pixel art game with 16 Pixels per unit.
After researching I finally found a fix for my problem. My problem was that the player got stuck inbetween my tiles each having a boxcollider with the TilemapCollider2D. I fixed it by removing each collider to one whole with a composite:
add TilemapCollider2D to the tile layer's component
check "used by composite" field in TilemapCollider2D
set Rigidbody2D to static
I had to check composite collider to polygons because otherwise I could not apply any Force to the rigidbody somehow.
I have a 2D environment where an object falls (a trap) and a box collider component is moved with a timeline to follow the movement with SetRelativeLocation.
Since the trap is near a wall if I leave the Sweep option unchecked in some cases the character will stuck mid air between the trap and the wall.
Sweep off
If I turn on Sweep this will not happen and the character is pushed to ground correctly but since the collider "slows down" for some frames it seems to be in the middle of the sprite.
Sweep on
Teleport option seems to have no effect on this behaviour.
Is there any way to have the sweep effect with the collider keeping his velocity and keeping the structure as it is with the collider moved by a timeline?
I feel like I'm missing something really simple but I'm losing my head on this.
Thanks!
Since it's 2D, have you tried blocking the input when your character collides? I would add a simple collider in front of your character and when it is overlapped, I'd limit the input in the direction your character goes, ie.:
Character collides right
MoveRight(float Scale): Clamp Scale to (-1.f, 0.f); AddMovementInput(...
Hope it helps!
I'm creating a fast-paced, 2D side-scrolling game on Unity 5.2, building my terrain out of discrete "blocks", each with its own EdgeCollider2D component.
Having a problem where my character gets bumped upward as it crosses from one block to another (imagine driving your car over a speed bump on the road).
This doesn't happen all the time. Seems to be random, which is even more irritating, as it makes finding a solution more difficult.
I've tried all of the suggestions that I could find for similar questions on this site, including:
Using CircleCollider2D's on the character
making sure the terrain blocks and their corresponding colliders are perfectly aligned. The attached screenshot shows one of the intersections.
changing the "Min penetration for penalty" setting to the minimum allowed value (0.0001)
switching between discrete and continuous collision detection for the character's RigidBody2D
increasing the mass and gravity scale for the character's RigidBody2D
... to no avail.
Beyond building a single, massive terrain object with a single edge collider from start to finish (which I'm trying to avoid), I've run out of ideas. Anything else I'm missing? Is it just a Unity bug?
Help!
Try detect the collision and set the vertical velocity to zero.
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name.StartsWith("block"))
rigidbody2d.velocity = new Vector2(rigidbody2d.velocity.x, 0);
}
Hello Peeps (first post yay).
I have just started to learn about unity and still going through various tutorials and learning the interface along with C#.
I am running Unity 4 and downloaded a free asset from the Unity store:
https://www.assetstore.unity3d.com/#/content/3174
The Problem.
I created a Plane in Unity.
Went to the Character and created colliders and imported it as a humanoid.
Then added a rigid body = The character fell through the plane
I then added a Mesh collider and attached the mesh for the character to the collider. The mesh does NOT align correctly to the character = the character fell through the plane.
I then tried box and capsule colliders and they worked fine. Attached these and the character would not fall through.
I then tried a character controller = Character did not fall through.
I want to have an accurate mesh for this test character so when an enemy hits him, there is an actual hit.
I have tried several other free characters from the store and they all have the same problem. Can someone please tell me how I can fix this? It seems I just either doing something completely wrong, missing a step or just plain lost.
Link below to image of the issue taken:
Using a mesh collider on a skinned, animated character is a wrong approach. Mesh colliders are generally used for environment geometry and rigid objects. This is all due to the amount of work it is needed for the Unity engine to accurately calculate the shape of the mesh collider, based on the provided mesh. More triangles means more work, and for the reasonably complex low poly character mesh of 10k to 30k triangles it is clear that the fps would most definitely drop to an unplayable level.
For our game we are using all primitive colliders, distributed on the adequate bone game objects. So, head bone has a sphere collider, spine has a box collider (for lungs), forearm has a capsule collider etc. That way,with a little bit of scripting, you can detect a hit and know exactly what part of body is damaged.
If your collider doesn't exactly match your mesh, then it's likely that you have the mesh applied to the wrong part of the object.
Try applying the Mesh Collider to the mesh, instead of the complete object.
You have a pretty complex character mesh, so using mesh collider probably isn't the best way to go. In many cases, character controller or capsule collider works fine; otherwise, you can just use compound collider and create a box or a sphere around various body parts of the character.
This once happened to me. The mistake i made was, i applied the mesh collider after i did some rotation and scaling. So i added the mesh collider as soon as i imported the model. And then it should be alright when you scale/edit the model. Also check with right/left handed co-ordinate system with unity and 3D MAX/Maya.