Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to target a head with PSYS_SRC_TARGET_KEY

Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
11-13-2007 12:11
Hi everybody,

I want to make a particle script that sent kiss particles to
a person that click on the prim for few seconds
the particle script works fine but i want to sent the particles to the persons head.

Does anyone know how i can target a persons head?

i used PSYS_SRC_TARGET_KEY to target the avatar but the particles is than
sent under the avatars feet.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-13-2007 15:12
best way i know to do it is have the prim generate another small prim that will go to whoever touched it and estimate about where there head would be
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
11-13-2007 15:17
Yes, that is probably the best bet. An avatar only has one key, which should be its centre - it is not made up of prims with different keys, like a linked object. Therefore, rez a prim (which you know the key of - the object_rez() event will tell you it) which moves to the position of an avatar but, say 1m upwards, then send the kisses to that.

The kiss target prim will need to have a timer event in it which automatically moves it to the avatar it is chasing's current location. I would use llGetObjectDetails and llSetPos for this. (Though if it is only for a few seconds, you may not need to bother.)
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-13-2007 22:45
don't really have to calculate a new prim

just send particles at it's calculated offset, with a range set to die at the calculated range(llVecMag( 0, offset) i think)...

oh Im so going to add this as a blow kisses function for a hugger attachment =)
_____________________
|
| . "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...
| -
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
11-14-2007 10:22
Thanks for the answers.

I will try to make this :))
especially i like the idea with llvegmag.
I don't know that command but will look at it at lslwiki.

But thanks to all for answering my question.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-14-2007 11:00
From: Void Singer
don't really have to calculate a new prim

just send particles at it's calculated offset, with a range set to die at the calculated range(llVecMag( 0, offset) i think)...

oh Im so going to add this as a blow kisses function for a hugger attachment =)


You can't "send" particles to a calculated anything. When you use PSYS_SRC_TARGET_KEY, they ALWAYS go to the center of the avatar/object/prim so specified.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-14-2007 21:43
when I say targeting offset, I don't mean feeding an offset directly to the particle script, I mean using angle, velocity and max age to send it to(at?) a specific offset (angle defined by angle between(?) & vector magnitude(aka range) redfined using velocity times max age)... not using PSYS_SRC_TARGET_KEY or PSYS_PART_TARGET_POS_MASK or PSYS_PART_TARGET_LINEAR_MASK

basically it's aiming a particle bullet at a target direction, and the bullet dies on reaching the target... yes with this the target can move, but that just adds to the cartoonish fun! =)
_____________________
|
| . "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
11-15-2007 00:29
Hi Void

Been watching this thread with interest.

Regarding your clarification of the "to die at the calculated range(llVecMag( 0, offset) i think)" suggestion:

From: Void Singer
using angle, velocity and max age to send it to(at?) a specific offset (angle defined by angle between(?) & vector magnitude(aka range) redfined using velocity times max age)... not using PSYS_SRC_TARGET_KEY or PSYS_PART_TARGET_POS_MASK or PSYS_PART_TARGET_LINEAR_MASK


This sounds a little vague, tbh, and indeed I have trouble seeing how this is "targeting" in its usual sense. The only way I can see that this would work in a reliable and consistant fashion is if you only fired the particles when the AV was in pre-defined position(s).

But even then it is not really "targeting", merely fireing a particle stream to a particular position when/if an AV just happens to be at that pre-defined position(s). Given also the vageries of AV height, you might fly over the head or hit the throat.

Perhaps I haven't fully followed your reasoning and you could post the code where you have gotton this to work.

As it happens, the only way I have gotton a particle to target the head is as others have already suggested, a variation on a bullet mechanism, and that is why I haven't previously chimed in on this thread :)
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-15-2007 08:01
Doing what you are describing is a difficult task at best.

1) You have to take into account avatar facing, and rotate the emitter so that it faces the target squarely. Any small deviations in facing can cause the particle stream to miss significantly.
2) If the avatar or target move AT ALL, it is likely to miss significantly.
3) Animations (including default ones that run all the time like "Look-at-who-is-talking";) will cause the stream to miss, and aim towards someone unintended. Since you can't detect such rotation via script, as it is only client-side, the stream will get sprayed around rather randomly quite often.

Basically, you are creating a stream breath weapon-style effect, but with some built-in smarts to compensate for the initial misalignment of the avatars, and doing a bit of math to control particle life. Using the ANGLE constants, set to anything other than 0.0 each, won't work because you get fans or cones of particles otherwise.

Ingenious as it may look on paper, in actual implementation, it will probably be very ugly.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-15-2007 08:11
roughly, because I'm close to bed time...

A=
llDetectedPos() to get target av's hip location
add 1m z to that, this is your target

B=
llGetPos() the particle emitter

C=
offset is A - B

D=
llGetVecDist( A, B )

velocity = C / 2; //-- think this will give steady 2 sec regardless of range

particle max age = D / velocity;

particle emiter aims at offset llSetRot( ZERO_ROTATION * llRotBetween( B, A )); //-- think this is it.

other flags as neccesary to shoot a single line of particles along the objects positive x axis... PSYS_SRC_ANGLE_END, 0.0 I think?
_____________________
|
| . "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...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-15-2007 08:45
From: Void Singer
roughly, because I'm close to bed time...


Wait until after you've slept some. :P

From: someone
A=
llDetectedPos() to get target av's hip location
add 1m z to that, this is your target

B=
llGetPos() the particle emitter


Since the emitter is likely to be an attachment, llGetPos() will give you the center of the av, so you will have to add a little less than 1/2 the avatar height to get a close approximation of the avatar's mouth.

From: someone
C=
offset is A - B

D=
llGetVecDist( A, B )

velocity = C / 2; //-- think this will give steady 2 sec regardless of range

particle max age = D / velocity;


C isn't required. Velocity is simply distance / time. Particle max age is set to the length of time you want the particles to take to get from the emitter to the target. If that is 2.0 seconds, that is what you set it to. You then would set both burst speeds to D / time (D / 2.0 in this case).

From: someone
particle emiter aims at offset llSetRot( ZERO_ROTATION * llRotBetween( B, A )); //-- think this is it.


I think you will find this calculation to be significantly more complex than that. First, assuming the avatar is in a static pose, with its head facing perfectly along llGetRootRotation(), then the function would be something more along the lines of llSetRot(llRotBetween(llRot2Fwd(llGetRootRotation()),B-A)). (That is not tested, and doing attachment rotations is VERY tricky, so it is probably wrong, but the point is to illustrate that it is fairly complex to get right)

From: someone
other flags as neccesary to shoot a single line of particles along the objects positive x axis... PSYS_SRC_ANGLE_END, 0.0 I think?


You can't shoot a *single* stream of particles in one direction except along the Z-axis of the emitter prim, using 0.0 for both ANGLE_BEGIN and ANGLE_END. Anything else, and you get fans, cones, or two streams of particles coming out the side of the emitter.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-15-2007 09:42
From: Talarus Luan
Since the emitter is likely to be an attachment, llGetPos() will give you the center of the av, so you will have to add a little less than 1/2 the avatar height to get a close approximation of the avatar's mouth.

1m was just a guesstimate.. the code for the avruler should work to get a good head height...

From: someone
C isn't required. Velocity is simply distance / time. Particle max age is set to the length of time you want the particles to take to get from the emitter to the target. If that is 2.0 seconds, that is what you set it to. You then would set both burst speeds to D / time (D / 2.0 in this case).

PSYS_SRC_ACCEL requires a vector, which also serves as a direction... (or so the wiki says) but that makes no sense since it (again by wiki) acceppt negative numbers... ok we'll go with BURST_SPEED_* =)

From: someone
I think you will find this calculation to be significantly more complex than that. First, assuming the avatar is in a static pose, with its head facing perfectly along llGetRootRotation(), then the function would be something more along the lines of llSetRot(llRotBetween(llRot2Fwd(llGetRootRotation()),B-A)). (That is not tested, and doing attachment rotations is VERY tricky, so it is probably wrong, but the point is to illustrate that it is fairly complex to get right)

I was simplifying in my head, I already want to play with this for a blow kiss attachment... for my lips... makes it a little easier I hope

From: someone
You can't shoot a *single* stream of particles in one direction except along the Z-axis of the emitter prim, using 0.0 for both ANGLE_BEGIN and ANGLE_END. Anything else, and you get fans, cones, or two streams of particles coming out the side of the emitter.

z? doh, for some reason I had sensors stuck in my head, using +x... so it'll require at least one more rotation, to brin z up by 90deg or is that down.... bah sleep....
_____________________
|
| . "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...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-15-2007 12:31
From: Void Singer
PSYS_SRC_ACCEL requires a vector, which also serves as a direction... (or so the wiki says) but that makes no sense since it (again by wiki) acceppt negative numbers... ok we'll go with BURST_SPEED_* =)


You don't want to use ACCEL, because it is /acceleration/, not /velocity/. It makes your calculations harder because the velocity is not constant.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
11-16-2007 02:20
Eventually re-stumbled on the wiki reference I knew was out there somewhere:

http://wiki.secondlife.com/wiki/LlParticleSystem section 'Caveats'

From: someone

4. Particles moving towards a humanoid avatar, specified by PSYS_SRC_TARGET_KEY rule and setting the PSYS_PART_TARGET_POS_MASK flag, will end up at the geometric center of the avatar's bounding box which, unfortunately, make them appear to be striking the person in the groin area. If you want them to end up at another point on a target avatar, you instead have to place a target prim that is moved to the position where you wish them to end up, and use the key of that prim for the value of the PSYS_SRC_TARGET_KEY rule.


Any alternative reliable & consistant working solutions would be of great interest, assuming that the overhead of effort for those alternative solutions provides proportional benefit.

Otherwise the exercise is of purely acedemic value and the "traditional" solution in the quote above, and originally suggested in this thread by a few people, would be the way ahead, it seems to me :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-16-2007 23:02
In the interest of using my idea for my own comercial gain, I'm going to beg off this topic, but am not in the slightest offended if someone happens to continue working out the specifics of the idea.

I will say that not having to rez a prim provides less limited use. but will likely take a bit more NEW code.

=)
_____________________
|
| . "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...
| -
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
11-17-2007 11:25
Fwiw- In the past... I've set up something that targetted a person, and sent particles upward with ACCEL, they'd fly up, then come down, and shrink/fade-out before arriving at the target. Since they were coming down from above it the path would terminate relatively close to their head, not their groin.

If I were to try Void's suggestion, I'd get the distance and direction of the intended target, rez a temp emitter offset from the avatar to roughly mouth level (no need for fancy rotation math, because hopefully their mouth is roughly the same offset from their center as well). Pass the vector distance to the emitter via the rez object parameter... it shoots a stream (without accel, just min/max speed) that's timed to terminate at the set distance, and then kills the emitter.

Sure avatars will move... sure it's approximate... (most things to do with particles are approximate anyway. ;))

(obviously the most accurate way would be to have sender and receiver objects worn in the mouth that broadcast keys so that TARGET will hit the right thing. But god forbid the target of a kiss be consenting enough to wear something appropriate! =D =D)
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources.
Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas.
-
Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-17-2007 20:25
If you're going to bother rezzing a prim, then just place it as a target and make it easy on yourself.

I think the point of Void's solution was to avoid the need to rez prims, esp in areas where you can't.
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
11-18-2007 11:56
From: Talarus Luan
If you're going to bother rezzing a prim, then just place it as a target and make it easy on yourself.

I think the point of Void's solution was to avoid the need to rez prims, esp in areas where you can't.


Well... yeah, I did get that part, though wearing the receiver would be more accurate than rezzing a target prim offset to where you think someone's mouth might be.... I couldn't let the 'consentual' comment go unsaid though. ;)