void BeamAttack() { GetAnimRig().SetTrigger("Beam"); SlashBehavior beamu = Instantiate(beam); Vector3 offset = Vector2.zero; Vector2 playerPos = GetPlayer().transform.position; if (playerPos.y > transform.position.y && Mathf.Abs(transform.position.y - playerPos.y) < Mathf.Abs(transform.position.x - playerPos.x)) { offset += new Vector3(0, 100, 0); } if (playerPos.y < transform.position.y && Mathf.Abs(transform.position.y - playerPos.y) < Mathf.Abs(transform.position.x - playerPos.x)) { offset += new Vector3(0, -100, 0); } if (playerPos.x > transform.position.x && Mathf.Abs(transform.position.y - playerPos.y) > Mathf.Abs(transform.position.x - playerPos.x)) { offset += new Vector3(0, 100, 0); } if (playerPos.x < transform.position.x && Mathf.Abs(transform.position.y - playerPos.y) > Mathf.Abs(transform.position.x - playerPos.x)) { offset += new Vector3(0, -100, 0); } offset = transform.position + offset; beamu.SetEdges(transform.position, offset); beamu.transform.localScale = new Vector2(Vector2.Distance(transform.position, offset), 1f); beamu.transform.position = new Vector2((transform.position.x + offset.x) / 2, (transform.position.y + offset.y) / 2); beamu.transform.LookAt(transform.position); beamu.transform.rotation = new Quaternion(0, 0, beamu.transform.rotation.z, beamu.transform.rotation.w); }
void SpawnSlash(Vector2 start, Vector2 end) { SlashBehavior slesh = Instantiate(slosh); slesh.SetEdges(start, end); slesh.transform.localScale = new Vector2(Vector2.Distance(start, end), 1f); slesh.transform.position = new Vector2((start.x + end.x) / 2, (start.y + end.y) / 2); slesh.transform.LookAt(start); slesh.transform.rotation = new Quaternion(0, 0, slesh.transform.rotation.z, slesh.transform.rotation.w); }