Search Unity

RigidBody2D Player gets stuck...

Discussion in 'Scripting' started by boowman, Jul 24, 2014.

  1. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    Hello
    I am creating a 2D game and I am not using sprites I am using actual 3D objects.
    I am using Box Collider 2D by the way.
    I added a cube and I added this script to it.
    Code (CSharp):
    1.  
    2.     public float speed = 2f;
    3.  
    4.     void Update ()
    5.     {
    6.        rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
    7.     }
    8.  
    Everything works perfectly but the problem is that the cube sometimes just stops suddenly.
    It's like that cubes box collider is a little to high, the think is if I restart the game it might stop somewhere else.
    It happened before and I didn't know what was the problem.
    If anyone can help it would be great, thank you.
     
  2. herman111

    herman111

    Joined:
    May 11, 2014
    Posts:
    119
    try using a circle collider instead...they don't get stuck
     
  3. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    Ok I will give it a shot, thank you.