Instantiating A Prefab on my Character Troubles,Instantiating a Prefab
I'm new to Unity, and attempting to spawn a Firebolt in front of the character. The prefab I have already has the appearance and effect I need, and as soon as the object enters the game it moves forwards. What I am trying to do is have it spawn when I press 'Q', and then do what the prefab has already been designed to do.
When I attempt to do so, all it results in is the first firebolt from the original prefab firing perfectly, and the rest just a series of somewhat distant flashes of light. If it's any help, the prefab is called 'Firebolt' from the asset pack 'Fire and Spell Effects' from the Unity Asset Store. Here is the code I have so far:
public GameObject leFirebolt;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Q)){
Instantiate (leFirebolt, transform.position, transform.rotation);
}
}
}
Answer by Cuttlas-U · Mar 09, 2018 at 12:57 PM
hey; GetKey Is Not Good for Instantiaition ;
try using "GetKeyDown" cause it only happen once when u press;
tell me if problem is fixed or not ;
Answer by KC_Westicles · Mar 12, 2018 at 01:44 AM
It works much better now, thanks. Although, after six shots no more fireballs seem to be available. And when a few fireballs are fired in the same direction in a row, the ball itself vanishes, and a distant explosion can be seen.
Your answer
Follow this Question
Related Questions
Changing rotation of prefab 0 Answers
instantiate a prefab not working 0 Answers
Create gameobject in other scene... 0 Answers
Prefabs not instantiating after build 0 Answers