void SpawnReticle() { float zRot = gunPivot.rotation.eulerAngles.z * Mathf.Deg2Rad; Vector2 aimVector = new Vector2(Mathf.Cos(zRot), Mathf.Sin(zRot)); RaycastHit2D hit = Physics2D.Raycast(transform.position, aimVector, Mathf.Infinity, surfaceLayer); Vector2 spawnPoint = new Vector2(1000, 1000); Vector3 spawnRotation = Vector3.zero; bool onSurface = false; if (hit) { spawnRotation = hit.transform.gameObject.GetComponent <Surface> ().surfaceRotation; spawnPoint = hit.point; onSurface = true; } portalReticle = portalManager.GenerateReticle(playerNum, spawnPoint, spawnRotation); portalReticle.onSurface = onSurface; }