Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Simple particle direction

Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
12-05-2007 20:39
Hi all.

I have a prim that emits particles. It is a gun barrel.

the particles shoot straight and fast... problem: They do NOT emit in the direction the barrel is pointing at.... excatly 90 degrees off.

Imagine pointing a gun straight out away from you, pulling the trigger, and blowing off your foot.

That is my dilemma.

My code for the direction is:

PSYS_SRC_ANGLE_BEGIN, 0.0,
PSYS_SRC_ANGLE_END, 0.0,

changing the values to PI shoots upward.

Other values give wild spreads...


it seems that the axis of the prim is the issue... but dammit, barrels have a direction, so I can't change that, and also, I can NOT add prims.

how to get these particle bullets to point along the barrel?

Thanks!
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
12-05-2007 21:03
Particles emit in the direction of the Z axis of the prim. i would assume the barrel would be a cylinder, in which case, the Z axis would be the correct one. if it some other shape prim, i would simply attempt to turn it so the axis faces the correct direction. a bit hard to say without seeing the gun in question.
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-05-2007 23:02
From: Ryder Spearmann
Hi all.

I have a prim that emits particles. It is a gun barrel.

the particles shoot straight and fast... problem: They do NOT emit in the direction the barrel is pointing at.... excatly 90 degrees off.

Imagine pointing a gun straight out away from you, pulling the trigger, and blowing off your foot.

That is my dilemma.

My code for the direction is:

PSYS_SRC_ANGLE_BEGIN, 0.0,
PSYS_SRC_ANGLE_END, 0.0,

changing the values to PI shoots upward.

Other values give wild spreads...


it seems that the axis of the prim is the issue... but dammit, barrels have a direction, so I can't change that, and also, I can NOT add prims.

how to get these particle bullets to point along the barrel?

Thanks!

did you try the FOLLOW_MASK flag?
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
12-06-2007 01:37
See /54/4f/209783/1.html

which gives an explanation of and simple example of how to set up PSYS_PART_FOLLOW_SRC_MASK and getting particles to emit in a specific direction. :)
Sekker Thirroul
Registered User
Join date: 27 Aug 2006
Posts: 28
12-06-2007 02:04
I'd guess your using a tube rather than a cylinder since a tubes Z axis is not along its length, if you can edit linked parts (which I figure you might not be able to sinceyou can't add prims?) you can bring up the stretch controls and the blue boxes show z axis.

Switchign the tube for a hollowed cylinder would be the easy option if you can without messing up the build
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
12-06-2007 04:47
Make the barrel of the gun out of a cylinder (not a tube) and set to appropriate sizes, say

x = 0.05
y = 0.05
z = 1.25

set the rotation to:

x = 0.00
y = 90.00
z = 0.00

Use the following llParticleSystem call:

From: someone

llParticleSystem([
PSYS_PART_FLAGS, PSYS_PART_FOLLOW_SRC_MASK,
PSYS_SRC_PATTERN, 4,
PSYS_PART_START_ALPHA, 1.00,
PSYS_PART_END_ALPHA, 0.00,
PSYS_PART_START_COLOR, <1.00,0.00,1.00>,
PSYS_PART_END_COLOR, <1.00,1.00,0.00>,
PSYS_PART_START_SCALE, <0.05,0.05,0.00>,
PSYS_PART_END_SCALE, <0.05,0.05,0.00>,
PSYS_PART_MAX_AGE, 3.50,
PSYS_SRC_MAX_AGE, 0.00,
PSYS_SRC_ACCEL, <0.00,0.00,0.00>,
PSYS_SRC_ANGLE_BEGIN, 0.00,
PSYS_SRC_ANGLE_END, 0.00,
PSYS_SRC_BURST_PART_COUNT, 20,
PSYS_SRC_BURST_RADIUS, 0.00,
PSYS_SRC_BURST_RATE, 0.10,
PSYS_SRC_BURST_SPEED_MIN, 7.50,
PSYS_SRC_BURST_SPEED_MAX, 7.50,
PSYS_SRC_OMEGA, <0.00,0.00,0.00>,
PSYS_SRC_TEXTURE, "a96ecd50-96e1-28b4-51ec-96b3112210c0"
]);


The particles will shoot in the direction that the end of the gun barrel is facing.
Keep PSYS_PART_FOLLOW_SRC_MASK in place but add any other necessary flags for the effect that you are trying to create; change the texture, colour, speed etc etc to suit.

The above llParticleSystem call provides a handy template for any 'directional' particle effects :)
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
12-06-2007 08:06
As stated above, the only solution is to fix the emitter prim to point in the correct direction, or use another tiny, invisible prim which is, if you can't change the build. Chances are, if you are using a cylinder as the barrel, you can put the particle system script in it and control it with link messages, if the root prim with the rest of the code is elsewhere.

PSYS_PART_FOLLOW_SRC_MASK isn't a good choice for guns, because it will move the whole particle stream with the gun and avatar, but not like people think it does. It won't change the direction of the particles at all, only their path of movement in a wholesale fashion. Basically it works like this:

Emit Particle:
Base_Position = Emitter_Position;
Offset = (initial transformations using the emitter position as the origin);
Particle_Position = Base_Position + Offset;

Update_Particle:
Offset = (updated transformations);
if (PSYS_PART_FOLLOW_SRC_MASK is set)
Base_Position = Emitter_Position; // Make the particle position "follow" the emitter position; note that rotation is NOT included!
Particle_Position = Base_Position + Offset;
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
12-06-2007 21:21
From: Darien Caldwell
Particles emit in the direction of the Z axis of the prim. i would assume the barrel would be a cylinder, in which case, the Z axis would be the correct one. if it some other shape prim, i would simply attempt to turn it so the axis faces the correct direction. a bit hard to say without seeing the gun in question.



Actually, it is a tube... a vastly more useable cylindrical shape.

I do not have the option of using a different prim.
I do not have the option of adding a prim.

The Tube seems to be the crux of the issue!
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
12-06-2007 21:41
From: Ryder Spearmann
Actually, it is a tube... a vastly more useable cylindrical shape.

I do not have the option of using a different prim.
I do not have the option of adding a prim.

The Tube seems to be the crux of the issue!



Indeed, I've used tube extensively, but i never noticed the Z Axis doesn't take the same direction as the Cylinder. How unfortunate. :\
_____________________
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
12-07-2007 09:18
The maths are beyond me, but it should be possible to set PSYS_SRC_ACCEL based on the rotation of the barrel to accelerate the particles in the correct direction.