# Unlimited friction when moving plane

Discussion in 'Physics' started by Marcel50506, Feb 11, 2015.

1. ### Marcel50506

Joined:
Mar 19, 2014
Posts:
2
Hi all,

I'm just starting with Unity, and having some problems with the whole physics/movement things. I know there are some ground rules when using (kinematic) rigidbodies in combination with movement/forces, but I can't figure out how to solve the problem below.

I'm creating a 3d game with a moving container, in which cubes fall down. Think Tetris. Only here the user is controlling the container instead of the falling cubes. In my current setup, the container is a kinematic rigidbody, without gravity. The floor of the container has a material with high values for (static and dynamic) friction. The cube also is a rigidbody, but with gravity and not kinematic.

Since the container should always move 1 unit to the front/rear/side, I vector3.lerp the whole container 1 unit in X or Z direction on keyDown.

Problem
The problem I have is that when the cube lands on the floor of the container, it almost doesn't move when the container is moving. Adding loads of friction doesn't do anything, although apparently there is a bit of friction since the cube is moving a bit.. My goal is 'unlimited friction', meaning that a cube on the floor shouldn't move at all, relative to the floor.

I don't know how to achieve this, would be really nice if someone could give some hints!

Thanks!

2. ### Billy4184

Joined:
Jul 7, 2014
Posts:
6,006
Hi, as always, the documentation is a good place to start. A kinematic rigidbody is not affected in any way by physical forces, but can affect objects with non-kinematic rigidbodies. The most common example is the ground or anything that you only want to be affected by what you've written in a script - not by physical interactions with other objects.

If you want your objects not to move at all under any circumstances once they hit the container, I suggest that upon collision you a) make them a child object of the container and b) change their rigidbodies to kinematic.

a) means that they will move with the container and b) means that collision with other objects won't affect them or move them.

Hope this helps,
William

Marcel50506 likes this.
3. ### Marcel50506

Joined:
Mar 19, 2014
Posts:
2

I didn't think of making the cubes a child of the container at collision. I understand why that works, but it feels a bit odd to me. I probably need to get into the whole way of Unity thinking, and not try to mimic a real world thing.

Anyhow, thanks a bunch!

4. ### bloomingdedalus

Joined:
Aug 13, 2012
Posts:
139
No, if you don't intend your falling bodies to be affected by physics anymore - you should definitely parent them to the container on collision...

Honestly, if I were making a tetris like game, I probably wouldn't transform the pieces by physics anyway but through manual scripting.

Using the physics friction is a terrible way to encourage objects to move unless your plane is also kinematic. Even then, it's going to be very glitchy.

However, I don't really know what kind of effect you're going for, so maybe having the pieces under physics is what you're going for. Physics is for stuff like rockets or kicking buckets around on the floor or marble games. Something like Tetris which requires object to conform to a grid is almost always going to be disastrous to try to use with the physics engine. There's too many quirks to the physics engine to ensure objects will behave predictably.

Marcel50506 likes this.
5. ### Billy4184

Joined:
Jul 7, 2014
Posts:
6,006
That's exactly right. You haven't signed a contract to leave everything to the physics engine so if you want to be sure of something it is best to use the simplest, surest option available. You'll be surprised how many things even in realistic games are manipulated directly by script and then dressed up to look as if the whole thing is part of the of the 'real world' physics of the game. For example, (as you might know) you won't find a character in a game that is actually balancing themselves on each foot, rather they are prevented from rotating at all and the animation is such that their movements appear to be balanced. That way you don't have to take a Phd in robotics just to animate a character

It isn't a shortcut, it just means that you've found the most efficient method to give the player the game experience.

Marcel50506 likes this.