public void CastSplat(Vector3 position) { Ray ray = Camera.main.ScreenPointToRay(transform.position); RaycastHit2D hit = Physics2D.GetRayIntersection(ray, Mathf.Infinity, layerMask); if (hit.collider != null) { GameObject splat = Instantiate(splatPrefab, position, Quaternion.identity) as GameObject; splat.transform.SetParent(splatHolder, true); Splat splatScript = splat.GetComponent <Splat>(); ParticleSystem particle = Instantiate(splatParticles, position, Quaternion.identity); //particle.Play(); Debug.DrawRay(position, hit.point, Color.red, 5f); if (hit.collider.gameObject.tag == "Background") { splatScript.Initialize(Splat.SplatLocation.Background); } else { splatScript.Initialize(Splat.SplatLocation.Foreground); } } Destroy(gameObject, 5f); }
private void OnParticleCollision(GameObject other) { ParticlePhysicsExtensions.GetCollisionEvents(splatterParticle, other, collisionEvents); int count = collisionEvents.Count; for (int i = 0; i < count; i++) { GameObject splat = Instantiate(splatPrefab, collisionEvents[i].intersection, Quaternion.identity) as GameObject; splat.transform.SetParent(splatHolder, true); Splat splatScript = splat.GetComponent <Splat>(); splatScript.Initialize(Splat.SplatLocation.Foreground); } }
private void OnParticleCollision(GameObject other) { ParticlePhysicsExtensions.GetCollisionEvents(splatParticles, other, collisionEvents); int count = collisionEvents.Count; for (int i = 0; i < count; i++) { GameObject splat = Instantiate(splatPrefab, collisionEvents[i].intersection, Quaternion.identity) as GameObject; // splat.transform.SetParent(splatHolder, true); // var main = splatParticles.colorOverLifetime; splat.GetComponent <SpriteRenderer>().color = splatParticles.main.startColor.color; Splat splatScript = splat.GetComponent <Splat>(); splatScript.Initialize(Splat.SplatLocation.Foreground); } }