# Particle Effect Instantiating in the Wrong Place

 0 How do I stop the blood splatter from instantiating underneath the enemies? I want them to spawn where the sword hits. `````` var isTriggered:boolean; function OnTriggerExit(other: Collider) { if (other.CompareTag("Sword")&&!isTriggered) { isTriggered=true; SwordSwing(); } } function SwordSwing() { playersStats = player.GetComponent(XPBar); health -= playersStats.playersAttack - defense * .1; // create a new blood splat var instantiatedbloodParticle : Rigidbody = Instantiate(bloodParticle, transform.position, transform.rotation); isTriggered=false; } `````` more ▼ asked May 25 '12 at 02:19 AM BHS 206 ● 27 ● 46 ● 53 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 You can get the point where the collision occurred at, then Instantiate the blood splatter at the point of collision. You can use the normal of the collision to determine which way the particles should squirt from. Here is the reference for Collision contacts. Take a look at the second example, this shows how to use both point and normal. ``````function OnCollisionEnter(other: Collision) { if (other.CompareTag("Sword")&&!isTriggered) { isTriggered=true; SwordSwing(other.contacts); } } function SwordSwing(contacts:ContactPoint[]) { playersStats = player.GetComponent(XPBar); health -= playersStats.playersAttack - defense * .1; // create a new blood splat var point=contacts[0].point; var normal=contacts[0].normal; var rotation = Quaternion.FromToRotation(-Vector3.up, normal); Instantiate(bloodParticle , point , rotation); isTriggered=false; } ``````You may need to fool around with the rotation. Im guessing it should go in the direction of the sword. You may even do away with the normal and just use the swords direction. more ▼ answered May 25 '12 at 02:31 AM hijinxbassist 2.1k ● 23 ● 31 ● 38 Thanks, but I get an error every time I come in contact with the enemy. It has something to do with the contacts. May 25 '12 at 06:36 AM BHS add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: