2D Space Shooter Raycast Problem

I have a problem at my unity project. I am trying to fire a raycast straight upwards from my playership and the raycast should hit the enemy. For that I am using a start and an end point, but the raycast ist always from the start point to the camera. I dont know how to fix it,please help me :smiley:


RaycastHit2D hit = Physics2D.Raycast(BeamFirepoint.transform.position,BeamFireTo.transform.position,6f);
			//RaycastHit2D hit = Physics2D.Raycast(BeamFirepoint.transform.position,-Vector2.up);

If you want to raycast straight upwards, then this bit of code should work

RaycastHit2D raycastUp = Physics2D.Raycast(transform.position, Vector2.up)

The transform.position part is assuming you have this script attached to the ship.