- Home /
Vibration when moving into colliders
Hi, I'm developing a 2D/3D mixture game where I have 2D sprites with box colliders standing and moving on their 3D environments. I figured out how to move the PC and change sprite animations but when I move into a collider which is a wall in this case, there is a vibration like it's trying to kick me back.
This is the video that shows the issue: http://www.youtube.com/watch?v=Izll396aFJw
These are my Physics settings:
Would be so nice if you could help me get rid of this problem. Thanks.
EDIT1: The problem kind of disappears when I change my Fixed Timestep from 0.01 to 0.008. It is not the solution of course but I may stay with it since I couldn't manage to control my character by velocity and addForce.
I use horizontal and vertical axises and give my vectors x and z values for it to move on horizontal space but the character hovers up. And also it doesn't seem to be moving xz or -xz directions.
By the way when I do it only on 2D it works and there is no vibration anymore.
How are you moving your character? Remember that you can not use Transform.Translate to move GameObjects if you want them to be affected properly by collisions. This **tutorial ** shows how it moves a character around using a rigidbody ins$$anonymous$$d and changing velocities.
I'm really new to Unity and C#, trying to learn much as I can. I have a Rigidbody and a Box Collider at the same time on my character. $$anonymous$$oving it by transform.translate. Probably that's the problem. Let's see if I can manage to do it. Thanks for the tutorial.
Can you give 0.01 value for $$anonymous$$in Penetration For Penalty at your Physics Settings
It gives the same result. I played around a lot with physics settings and couldn't find a solution. Only thing seems to fix it is changing Fixed Timestep from 0.01 to 0.008 but I know it is not a good way to do it.
Transform.Translate does not take collision into account and basically teleports the GameObject to the new position no matter what is already there. $$anonymous$$oving the Rigidbody as described in the tutorial I linked should solve your problem. =)
Answer by sarahnorthway · Sep 12, 2017 at 11:07 PM
Use rigidbody.MovePosition instead of transform.position.
private const float speed = 14f;
private void Update() {
// includes wasd, arrow keys and controller sticks
Vector3 moveDirection = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
// results in vibration:
//transform.position += moveDirection * speed * Time.deltaTime;
// no vibration:
Rigidbody rigidbody = GetComponent<Rigidbody>();
rigidbody.MovePosition(rigidbody.position + moveDirection * speed * Time.deltaTime);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613130505im_/https://answers.unity.com/themes/thub/images/avi.jpg)