private void OnCollisionEnter(Collision collision) { MyShaderBehavior script = collision.collider.GetComponent <MyShaderBehavior>(); script.PaintOn(moveCharacter.coord, splashTexture); Destroy(gameObject); }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.forward, out hit)) { MyShaderBehavior script = hit.collider.gameObject.GetComponent <MyShaderBehavior>(); if (null != script) { script.PaintOn(hit.textureCoord, ChangePaintColour()); } } } if (Input.GetKeyDown(KeyCode.Alpha1)) { paintColour = PaintColour.Random; } if (Input.GetKeyDown(KeyCode.Alpha2)) { paintColour = PaintColour.Blue; } if (Input.GetKeyDown(KeyCode.Alpha3)) { paintColour = PaintColour.Pink; } if (Input.GetKeyDown(KeyCode.Alpha4)) { paintColour = PaintColour.Yellow; } }
private void OnCollisionEnter(Collision collision) { RaycastHit hit = new RaycastHit(); Ray ray = new Ray(collision.contacts[0].point - collision.contacts[0].normal, collision.contacts[0].normal); if (Physics.Raycast(ray, out hit)) { MyShaderBehavior script = collision.collider.gameObject.GetComponent <MyShaderBehavior>(); if (null != script) { script.PaintOn(hit.textureCoord, splashTexture); } } }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.forward, out hit)) { MyShaderBehavior script = hit.collider.gameObject.GetComponent <MyShaderBehavior>(); if (null != script) { script.PaintOn(hit.textureCoord, splashTexture); } } } }
void OnTriggerEnter(Collider other) { // Adds paintballs to the pool PaintballPool.instance.AddPaintballToPool(gameObject); // creates particle effects. ParticleSystem cloudParticle = Instantiate(PaintProjectileManager.GetInstance().cloudParticlePrefab); ParticleSystem burstParticle = Instantiate(PaintProjectileManager.GetInstance().burstParticlePrefab); MyShaderBehavior script = null; cloudParticle.transform.position = transform.position; burstParticle.transform.position = transform.position; var cloudSettings = cloudParticle.main; var burstSettings = burstParticle.main; cloudSettings.startColor = paintColor; burstSettings.startColor = paintColor; cloudParticle.Play(); burstParticle.Play(); PaintProjectileManager manager = PaintProjectileManager.GetInstance(); for (int i = 0; i < 14; ++i) { if (Physics.Raycast(transform.position, manager.GetSphereRay(i), out RaycastHit hit, paintDiameter)) { if (hit.collider is MeshCollider) { script = hit.collider.gameObject.GetComponent <MyShaderBehavior>(); if (null != script) { script.PaintOnColored(hit.textureCoord2, manager.GetRandomProjectileSplash(), paintColor); script.PaintOnColored(hit.textureCoord2, manager.GetRandomProjectileSplash(), paintColor); } } } } if (script != null) { float value = TextureColorFillCalculator.CalculateFill(GetObjectTexture().GetPixels(), paintColor, 0) * 100; menuController.SetSliderValue(value); } }
void OnTriggerEnter(Collider other) { if (!isActive) { return; } Destroy(gameObject); ParticleSystem cloudParticle = Instantiate(GameManager.GetInstance().GetProjectileManager().cloudParticlePrefab); ParticleSystem burstParticle = Instantiate(GameManager.GetInstance().GetProjectileManager().burstParticlePrefab); cloudParticle.transform.position = transform.position; burstParticle.transform.position = transform.position; var cloudSettings = cloudParticle.main; cloudSettings.startColor = paintColor; var burstSettings = burstParticle.main; burstSettings.startColor = paintColor; cloudParticle.Play(); burstParticle.Play(); PaintProjectileManager manager = GameManager.GetInstance().GetProjectileManager(); for (int i = 0; i < 14; ++i) { RaycastHit hit; if (Physics.Raycast(transform.position, manager.GetRandomSphereRay() /*GetSphereRay(i)*/, out hit, paintDiameter)) { if (hit.collider is MeshCollider) { MyShaderBehavior script = hit.collider.gameObject.GetComponent <MyShaderBehavior>(); if (null != script) { script.PaintOnColored(hit.textureCoord2, manager.GetRandomProjectileSplash(), paintColor); } } } } INpcBehavior npcScript = other.GetComponent <INpcBehavior>(); if (null != npcScript) { npcScript.DealDamage(damage); } }