// Use this for initialization void Start() { var rigibody = gameObject.AddComponent <Rigidbody>(); var boxCollider = gameObject.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(0.6f, 0.6f, 0.6f); var meshFilter = gameObject.AddComponent <MeshFilter>(); meshFilter.mesh = MeshUtil.CubeMesh(0.6f); var meshRenderer = gameObject.AddComponent <MeshRenderer>(); rigibody.velocity = Direction; var p = CastPoint; p.z = -1; gameObject.transform.position = p; StartCoroutine(ZapRoutine()); }
// Use this for initialization void Start() { CastPoint.z = -0.5f; transform.position = CastPoint; var boxCollider = gameObject.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(0.33f, 0.33f, 0.33f); var meshFilter = gameObject.AddComponent <MeshFilter>(); meshFilter.mesh = MeshUtil.CubeMesh(0.33f); var meshRender = gameObject.AddComponent <MeshRenderer>(); var rigidbody = gameObject.AddComponent <Rigidbody>(); rigidbody.velocity = 5f * Direction; StartCoroutine(EmitTrail()); }