Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Why my clone gameobject cannot move?

$
0
0
The scene is that the player can automatically shoot enemies if close enough. The shooting will be lasted if the enemy in player's range. The issue is that every bullets just cloned but can't move. Also, to some reason, i didn't add rigidbody for the bullet prefeb. Here's my code: if (Vector3.Distance (player.position, enemy.transform.position) < PLAYER_ATTACK_DISTANCE) { if (Time.time > nextFire) { nextFire = Time.time + fireRate; GameObject b = Instantiate (bullet, transform.position, transform.rotation) as GameObject; b.transform.position = Vector3.MoveTowards (transform.position, enemy.transform.position, Time.deltaTime * moveSpeed); } }

Viewing all articles
Browse latest Browse all 508

Trending Articles



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