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

Random Enemy 2D C#

$
0
0
Hey guys. I have a problem with my code. I want to make an enemy that it can show up everywhere and when I click that I get a poin, and the problem is when I run it the enemy doesn't show up. I thing there is a problem with this RandomScript. Can you help me guys? Here's the script..... public class RandomScript : MonoBehaviour { public GameObject[] bocor; public GameObject[] bocorSedang; public GameObject[] bocorBesar; public Transform bocorK; public Transform bocorS; public Transform bocorB; Transform bolong; void SpawnBocor(){ float x = Random.Range (5, 5); float y = Random.Range (5, 5); int R = Random.Range (-100, 100); switch (R) { case 0: bolong = Instantiate(bocorK) as Transform; break; case 1: bolong = Instantiate(bocorS) as Transform; break; case 2: bolong = Instantiate(bocorB) as Transform; break; } bolong.position = new Vector3 (x, y, 5); } void Start(){ InvokeRepeating ("SpawnBocor", 1f, 4f); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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