Hello I'm making summoning script in my topdown 2d game that get random position from player
Want to summon enemy in the direction you're looking at
Code (CSharp):
- public Vector3 GetRandomPosition()
- {
- float radius = 50f;
- Vector3 playerPosition = player.transform.position;
- float a = playerPosition.x;
- float b = playerPosition.y;
- float x = Random.Range(-radius + a, radius + a);
- float y_b = Mathf.Sqrt(Mathf.Pow(radius, 2) - Mathf.Pow(x - a, 2));
- y_b *= Random.Range(0, 2) == 0 ? -1 : 1;...