- Home /
[2D] Bug ground collision
Hi! I'm beginning with Unity, and I tried to do a base for a platformer game, in 2D. I just have a caracter moving to left and to right, and he can jump.
I use some "blocks" to do the ground.
My problem is here : My caracter moves perfectly, but sometime, he stop moving at the intersection of two blocks. I don't understand why, my blocks are perfectly aligned.
Someone know why? Thanks in advance!
(Sorry for my bad english)
I'd check the colliders. But without any code it's really hard to give you any help.
Here's my only script, for my caracter :
using UnityEngine;
using System.Collections;
public class PlayerScript : $$anonymous$$onoBehaviour {
public Vector2 speed = new Vector2(0,0);
public Vector2 movement = new Vector2(0, 0);
void Update()
{
float inputX = Input.GetAxis("Horizontal");
bool jump = Input.GetButtonDown("Jump");
speed.x = inputX * 10;
if (jump)
speed.y = 10;
else
speed.y = rigidbody2D.velocity.y;
movement = new Vector2(speed.x, speed.y);
}
void FixedUpdate()
{
rigidbody2D.velocity = movement;
}
}
I thought the problem didn't come from this, that's why I didn't post it.
I'm not sure if this works for 2D physics or just 3D, but perhaps you could test it. I think Unity still need to add an equivalent setting to 2D. Try changing $$anonymous$$in Penetration for Penalty
to 0
in Edit > Project Settings > Physics.
I think I found the problem! $$anonymous$$y caracter only had a box collider. I added a circle colider for his feet, and it works!
Thanks for all! (What I have to do to make my question "Solved"?)
Answer by Stending · May 21, 2014 at 06:20 PM
I found the problem! My caracter only had a box collider. I added a circle colider for his feet, and it works!
If you are happy with your answer, please click the "tick" to the left of your answer to accept and close the question.
Your answer

Follow this Question
Related Questions
Using child colliders with rigidbodies/joints in 2D 0 Answers
Problem with method Collider2D.isTouchingLayers() 4 Answers
Find next corner of a 2d pollygon collider 0 Answers
Character jittering when moving and constant back and forth when colliding. 1 Answer
Same script on two gameobjects, only the original(first) one is working 1 Answer