- Home /
jittery collisions 2d platformer
horizontalInput = Input.GetAxis("Horizontal");
transform.Translate(Vector3.right * horizontalInput * Time.deltaTime * speed);
So basically I'm having trouble with collisions on my 2d platformer, keep in mind this is my first ever game. I've googled a bit about my problem and found out that transform.Translate shouldn't be used in this type of game. But I couldn't find anywhere a solution which I can use instead of transform.Translate. My player goes through my "obstacles" when he is going at a fast speed. Also when explaining please ELI5 cause I'm pretty new to programming in general. Thanks in advance
Hey there, the appearance of jitter is usually caused by either moving an object into a collision outside of FixedUpdate / physics or by a camera that's moving just before its target.
In your case, you might get a more expected behavior by using a Rigidbody2D component for your character and setting its velocity
manually. This can be a bit taboo depending on who you're asking as it will naturally overwrite any physical motion calculated by Unity itself, but you will get pretty intuitive collider behavior.
Answer by WheresMommy · Dec 09, 2019 at 09:01 PM
You should look into rigidbody movement (forces etc.) instead of transform translating, as changing the transform will always be like a minimal transportation from point a to b in 0 time, so there is no actual communication between the physics engine and your object until it reached point b.
Your answer
Follow this Question
Related Questions
Can't change direction mid-jump 1 Answer
Player Tips - Have triggers act independently 1 Answer
Rolling Barrels through Platforms 0 Answers
Why isn't my instance of an object moving? 1 Answer
2D Combo Attack 1 Answer