Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Want to summon enemy in the direction you're looking at

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

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>