x


Projectile not creating particle effects on hit

I was implementing the FPS tutorial's "create explosion on hit" part to my project but my particle effects seems to be happening inside the object I am hitting rather than on the surface. I tried modifying the hit location a bit to see if the effect moves out of the object but it doesnt seem to work.

Here is my code:

var CreateSparks : Transform;

private var lifeTime : float = 0.05f;

function OnCollisionEnter(collision : Collision)

{

//Rotate the object so that the y-axis faces along the normal of the surface    
var contact : ContactPoint = collision.contacts[0];    
var rot : Quaternion = Quaternion.FromToRotation(Vector3.forward, contact.normal);    
var pos : Vector3 = contact.point;
Instantiate(CreateSparks,pos,rot);
Destroy(this.gameObject,lifeTime);   

}

more ▼

asked Mar 28 '12 at 06:03 PM

crocodile5 gravatar image

crocodile5
51 4 8 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

It's some problems with the collision. Because i had same code. And the bullet goes inside the object. When i removed the collsion code. It bounced like it should. But when i had the code there it went through the object. The only way to fix that is using raycast thing for collision.

more ▼

answered Apr 28 '12 at 05:35 PM

boilingfort gravatar image

boilingfort
36

Yep, apperantly my projectiles were too fast for the engine to calculate the hits. I rewrote the code with raycasts and it worked. Thanks.

Apr 30 '12 at 12:28 PM crocodile5
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x254
x6
x5

asked: Mar 28 '12 at 06:03 PM

Seen: 416 times

Last Updated: Apr 30 '12 at 12:28 PM