Search Unity

Ray cast to ignore player

Discussion in 'Scripting' started by DanteVFenris, Jan 19, 2014.

  1. DanteVFenris

    DanteVFenris

    Joined:
    Jan 19, 2014
    Posts:
    8
    var hit: RaycastHit2D = Physics2D.Raycast(transform.position, -Vector2.up);


    if (hit != null) {
    print("hit object");
    }
    I am very new to unity.




    So basically this is a test. I need this to work to get what i want to work. So with my ray i want to cast it up from the player and hit a object. There is multiple problems i am having, first even when there is nothing in the area that is up it hits something. Second other code ive tried to use will hit my players collider, and only will work when i put it off put that causes even more er
     
  2. DanteVFenris

    DanteVFenris

    Joined:
    Jan 19, 2014
    Posts:
    8
    i realize i said up, when theres nothing down it still collides. Even when there is nothing in the entire map that it can collide with, it somehow finds something to collide with
     
  3. MDragon

    MDragon

    Joined:
    Dec 26, 2013
    Posts:
    329