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
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
Limit the distance that the raycast works: http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html Also, look at both the distance and LayerMask properties. Use those to solve this issue