Question by
Hackenburg · Nov 13, 2018 at 05:36 PM ·
spawnenum
Using Direction enum to move an enemy from off screen
Hello, I am building an Asteroids game in Unity and I need to spawn the asteroids outside of the screen on all sides (Left, Right, Bottom, and Top). I also need to have them move in that direction at a random angle. For example, if the asteroid that is on the bottom of the screen is going to move into the camera view, I need to use Direction.Up and move it at a random angle between 75 x Mathf.Deg2Rad, and 105 x Mathf.Deg2Rad. I am struggling with figuring out how to properly use the Direction.Up to allow this to happen. I'm not sure whether to use an if statement or something else. I do want to say that I am new to Unity and am looking to get better so any help is appreciated.
Comment
Your answer
