Question by
VSwedeHD · Jun 02, 2017 at 05:42 PM ·
c#gameobjectinstantiate
error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists
I'm trying to make a shooter game, and i'm trying to edit the code for the bullet impact effect to make it disappear. but it comes up with this error. error CS0266: Cannot implicitly convert type UnityEngine.Object
to UnityEngine.GameObject
. An explicit conversion exists (are you missing a cast?)
GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
Destroy (impactGO, 2f);
using UnityEngine;
Comment
Wiki
Answer by BaldBeardedMonk · Jun 03, 2017 at 04:08 AM
GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)) as GameObject;
OR
GameObject impactGO = (GameObject) Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
Your answer
Follow this Question
Related Questions
Instantiate as child for gameobjects with tag 1 Answer
Attach a shield to player (C#) 2 Answers
No gameobject instance again in update 1 Answer