Hi
I have this script, but the RayCast2D stops at the first object it is inside (Mining laser attached to SpaceShip), so it basically stops at Spaceship.
Vector2 direction = transform.TransformDirection(Vector2.up);
RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, Mathf.Infinity);
if (hit.collider != null && hit.collider.tag != "Ship_PlayerSpaceShip")
distance = Vector2.Distance(transform.position, hit.point);
else
distance = 25;
if (distance > 25)
distance = 25;
gameObject.GetComponent().SetPosition(1, new Vector3(0, distance * 2, 0));
When I disable collider of that Ship, laser object(object from which raycast is cast forward in 2d space ofc) all is working fine. So for example laser colliders with asteroid and it has nice effect.
However when I turn On the Ships Collider, the raycast stops there and refuses to go further to check for other collision.
Please help I am getting crazy from that
↧