Search Unity

My colliders are not where the gameobject is drawn

Discussion in 'Editor & General Support' started by mexicanlefty, Oct 17, 2019.

  1. mexicanlefty

    mexicanlefty

    Joined:
    Oct 17, 2019
    Posts:
    7
    Im working on is this tutorial to better understand unity, it is my first time using it : https://learn.unity.com/project/ruby-s-2d-rpg
    Specifically at this part is where i got the issue https://learn.unity.com/tutorial/wo...g-movement?projectId=5c6166dbedbc2a0021b1bc7c

    I been following the tutorial step by step exactly as it is written, i added a rigidbody to the character and some of the gameobjects and disabled gravity, i added a collider to the character to the boxes and to the tilemap with water surface. This is an screenshot of how it looks right now: https://imgur.com/YYfIGBU And this is an screenshot when in playmode: https://imgur.com/tR4YSMw

    This started when i did the step of adding this code: public class RubyController : MonoBehaviour { Rigidbody2D rigidbody2d;

    // Start is called before the first frame update
    void Start()
    {
    rigidbody2d = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
    float horizontal = Input.GetAxis("Horizontal");
    float vertical = Input.GetAxis("Vertical");

    Vector2 position = rigidbody2d.position;
    position.x = position.x + 3.0f* horizontal * Time.deltaTime;
    position.y = position.y + 3.0f * vertical * Time.deltaTime;

    rigidbody2d.MovePosition(position);
    }

    }

    After adding that piece of code the issue started, the colliders are supposed to be at the water and the two brown boxes, however i can pass through them and i collide several tiles later to the right in this image i put in red where i actually collide and in yellow where the collider is supposed to be: https://imgur.com/imPjpTD

    So as you can see the colliders also changed in size but the others gameobjects and tiles are not getting bigger as the main character, anyone knows how to solve this?