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

transform.position assign attempt for 'Cubie' is not valid. Input position is { NaN, NaN, NaN }.

$
0
0
![alt text][1] So here's some background information, I am trying to create this explosion effect of "cubie's". I have one object called enemy that when he collides with a bullet it destroys itself and instantiates another object called EnemyDeathAnimation which is not really an animation but a gameObject that replicates an explosion effect based on this tutorial: http://gamedevelopment.tutsplus.com/tutorials/how-to-make-an-object-shatter-into-smaller-fragments-in-unity--gamedev-11795 when I play the game and shoot the enemies occasionally I get the NaN error. I think it may be caused by the sphere used in the explosion effect instantiating and interfering with other objects. If anyone could shed some light on how to avoid/fix the error that would be great. If there is any better way of creating the explosion effect I would be more than happy to scratch this method and do it that way. Enemy Script: using UnityEngine; using System.Collections; public class EnemyCubeScript : MonoBehaviour { public GameObject deathAnimation; private float fadeTimer = 1.9f; private Transform player; private NavMeshAgent nav; void OnTriggerEnter (Collider col) { if(col.tag == "Bullet") { GameObject deathAnimationClone = Instantiate(deathAnimation, transform.position, transform.rotation) as GameObject; //instantiates deathAnimation gameObject Destroy (gameObject); //destroy self Destroy (deathAnimationClone, fadeTimer); Destroy (col.gameObject); //destroy bullet } } void Awake () { player = GameObject.FindGameObjectWithTag ("Player").transform; nav = GetComponent (); } void Update () { nav.SetDestination (player.position); } } [1]: /storage/temp/36013-nan+error.png

Viewing all articles
Browse latest Browse all 508


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