Wesley
Wesley

Reputation: 57

Unity particle system does not rotate correctly

I'm having a small issue where the particle system is not behaving the way I command it to.

I made a blob, that jumps / dashes. When-ever he does, I spawn in particles that will give him a dash effect. ( When the blob dashes right, the particles go left, etc.. )

The problem is that my dash effect works for Left and Right ( Rotation of the particle system -90 & 90 ). When I jump UP and DOWN I rotate the particle system to 0 & 180, how ever the up and down particle's don't rotate. ( See GIF ).

I tried this in 2 ways, code and a pre-set prefab for every angle, the code looks as following

//The method takes a Vector3 Rotation e.g : ( 0,90,0 )
//This only works for left and right, not for up and down ( 0 & 180 ).
//
private void ParticleSpawner(Vector3 rot)
{
    ParticleSystem ps = dashEffect.GetComponent<ParticleSystem>();
    var sh = ps.shape;
    sh.enabled = true;
    sh.shapeType = ParticleSystemShapeType.Cone;
    sh.rotation = rot;
    sh.angle = 33;
    sh.radius = .1f;
    Instantiate(dashEffect, transform.position, Quaternion.identity);
}

The prefab looks as following :

enter image description here

GIF : https://i.gyazo.com/3ecf2991f10d0ab763423aa254d72364.mp4

Upvotes: 2

Views: 1664

Answers (1)

Fix
Fix

Reputation: 198

You're rotating around the Y axis, so a 90 rotation will point left/right, but a 180 degree rotation will point to/away from the camera.

To rotate the particle system to point up and down, try rotating 90 degrees around the X axis.

Upvotes: 1

Related Questions