Question by
bellfeige · Apr 06, 2016 at 11:31 AM ·
clonemovetowardsclones
Why my clone gameobject cannot move?
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);
}
}
Comment
Your answer
Follow this Question
Related Questions
Making clones of a GameObject but then the original gets destroyed 0 Answers
Instantiate problem, spawning too many clones, then cloning the clones! help! 0 Answers
Exponential Instantiation 0 Answers
I have searched like the whole Internet for this lol (get Value of specific Prefab(clone)) 2 Answers