Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with particle target setting

Katiana Milena
Registered User
Join date: 30 Oct 2007
Posts: 8
11-14-2007 11:26
Hi all, I have read everything I can find about targets, the Listen command and Keys on SL Wiki, and I am still stumped.

I am trying to have my particles go towards a target object. I have been able to successfully implement the key TARGET = llGetKey() command to have them gravitate towards the emitter, and the key TARGET = llGetOwner() command to have them gravitate towards me. I used the llOwnerSay(llGetKey()) command and got a key for my target... I just can't seem to put the pieces of the puzzle together.

If someone could walk me through the process of having the source prim recognize my intended target prim as a target, it would be much appreciated.

Thanks for your time, and your help!
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
11-14-2007 12:42
From the sound of things you are pretty much there or thereabouts :)

As you know, PSYS_SRC_TARGET_KEY is the parameter that has to be passed a key of the intended target, and also the PSYS_PART_TARGET_POS_MASK flag has to be set.

The value that you pass PSYS_SRC_TARGET_KEY can be obtained from any function or combination of functions that returns a key.

So you have already used llGetKey() & llGetOwner() but you could also use, say. llDetectedKey(0) from within a touch_start or sensor, eg:
target = llDetectedKey(0);

or even target towards a specific linked-prim, eg:
target = llGetLinkKey(9);

or a random linked-prim within the link-set, eg:
target = llGetLinkKey(llFloor(llFrand(llGetNumberOfPrims())));

The point is, so long as PSYS_SRC_TARGET_KEY is passed a valid key, and that PSYS_PART_TARGET_POS_MASK is set, then the particle stream will attempt to direct towards that target (all other things being equal: that is, range and other llParticleSystem parameters also have a bearing, but putting them aside for one moment for clarity)

The following example script gives an indication of how this might be used.

Note that PSYS_SRC_TARGET_KEY is passed the key value held within variable "target" and that PSYS_PART_FLAGS is passed a value of '64' (which sets PSYS_PART_TARGET_POS_MASK ). In this example PSYS_PART_TARGET_LINEAR_MASK has also been set, having a value of '128'. PSYS_PART_FLAGS is therefore passed the sum of these two, '192'.

The script does a number of things:
1) On compile (state_entry) it sets the target to a random prim within the set and fires off llParticleSystem() every five seconds using a timer. This random prim will remain the target until:
a) the object is touched, in which case the person touching the object becomes the target (touch_start)
or
b) a sensor detects an Agent with 5.0m of the object, in which case that detected agent become the target (sensor)
2) when no Agent is detected, the target reverts to being a random prim within the set ( non_sensor)

CODE

key target;

ParticleStart()
{
llSay(0, (string)target);
llParticleSystem([
PSYS_PART_START_SCALE,<0.3, 0.6, 0.0>,
PSYS_PART_END_SCALE,<0.0, 0.6, 0.0>,
PSYS_PART_START_COLOR,<0.3, 1.20, 0.0>,
PSYS_PART_END_COLOR,<1.0, 0.0, 0.3>,
PSYS_PART_START_ALPHA,1.0,
PSYS_PART_END_ALPHA,0.90,
PSYS_SRC_BURST_PART_COUNT,1,
PSYS_SRC_BURST_RATE,0.0,
PSYS_PART_MAX_AGE,1.25,
PSYS_SRC_MAX_AGE,2.3,
PSYS_SRC_PATTERN,8,
PSYS_SRC_BURST_RADIUS,0.05,
PSYS_SRC_ANGLE_BEGIN,0.0,
PSYS_SRC_ANGLE_END,0.017453,
PSYS_SRC_OMEGA,<0.0, 0.0, 0.0>,
PSYS_SRC_ACCEL,<0.0, 0.0, 0.0>,
PSYS_SRC_BURST_SPEED_MIN,0.01,
PSYS_SRC_BURST_SPEED_MAX,0.03,
//target parameter is passed a key
PSYS_SRC_TARGET_KEY, target,
//the value of PSYS_PART_TARGET_POS_MASK is '64' & //PSYS_PART_TARGET_LINEAR_MASK is '128' so PSYS_PART_FLAGS is passed '192'
PSYS_PART_FLAGS, ( 192 ) ]);
}

default
{

state_entry()
{
llSetTimerEvent(5.0);
target = llGetLinkKey(llFloor(llFrand(llGetNumberOfPrims())));
llSensorRepeat("",NULL_KEY,AGENT,5.0,PI,1.0);
}

touch_start(integer touches)
{
target = llDetectedKey(0);
}

sensor(integer number)
{
target = llDetectedKey(0);
}

no_sensor()
{
target = llGetLinkKey(llFloor(llFrand(llGetNumberOfPrims())));
}

timer()
{
ParticleStart();
}
}



Hope that helps :)
Katiana Milena
Registered User
Join date: 30 Oct 2007
Posts: 8
11-14-2007 13:49
Wow, that is quite a complex procedure! No wonder I was having trouble finishing.
Thanks a bunch for the helpful response Debbie, and the neat sensor feature in that script.
I will try and sift through that new information after work tonight, I'm going to have to read it over a few times I think =-)
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
11-15-2007 02:52
Hi Katiana

In practice, it is actually easier than it sounds when described in words ~ usually!

But in particle generation, each parameter plays-off of the other parameters and affects the overall stream. Sometimes the tinest of adjustments can make a huge difference, other times not. The only real way to learn this is to spend hours upon hours playing with the system, imo, and actually observing it. Although the wiki details the description of each parameter pretty well, it gives absoutely no indication of the subtleties of the system, nor of the interactions between the various parameters.

So when trying to answer a question like: "If someone could walk me through the process..." the hardest part in answering the thread is what do you decide to leave *out* of the answer, in order to maintain clarity and stick to the core point!

In the script example supplied above, I would suggest you try out the following. I'm sure it will clarify your original question and make my previous answer much clearer:

1) Construct a simple object comprising 5 to 10 individual linked-prims. Leave a gap of say 0.50m to 1.0m between each prim; use different heights. Link them up. But keep it simple

2) Pop the example script into the root-prim. From a distance of 6m to 10m away, recompile the script and observe the particle stream.

3) Walk up the the root-prim and wait a few seconds.

4) Walk 6m to 10m away from the root-prim and wait a few seconds.

5) From a distance of 6m to 10m away, touch the root-prim.

Hopefully you'll be able to match the changing behaviour of the particle stream with the various components of the example script and this will give you the final clues you'll need to "put the pieces of the puzzle together" :)

As with most things LSL, the wiki is your friend and first port-of call: http://rpgstats.com/wiki/index.php?title=LlParticleSystem

Good luck!