Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

spaceship 3D game enemy spawn concept

$
0
0
Am looking to for a concept to spawn enemies in a random position on screen. My game is a 3D space ship game where the player can yaw,strafe move around the 3d environment. However I have created a little script for the individual enemies. But I want to create a script in which the enemies will be spawned on different location on screen wherever the player moves. I have enemy spaceship, space obstacles and satellites. All these three enemies should be spawned on a random location where the player moves and disappear after some time. Thanks in advance Enemy Script { public Transform target; public float maxRange; public float minRange; public float rotationSpeed; public float speed; private bool follow; // Follow Enemy Switch void FixedUpdate() { Attack(); } private void Attack() // Enemy Attack Function { if((Vector3.Distance(transform.position,target.position)minRange)) { follow = true; // Enemy Switch Enabled } if(follow) // On enemy Switch Enabled { transform.LookAt(target);// Locking the target transform.Translate(Vector3.forward *speed* Time.deltaTime);// Forward Motion transform.Rotate(0,90,0); // Gimber Lock } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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