Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Event firing for avatar move?

Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-14-2006 06:35
Is there an event that fires when the avatar moves position? I've got a timer right now going off ever .2 seconds, but it would be great to just have something trigger when the avatar moves instead of constantly updating his position.
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
12-14-2006 06:54
I haven't used sensors much...but I know there's a way to call one to sense for when an avatar is flying...so you should be able to do walking or running as well.

I'd check the wiki for information about sensors
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
12-14-2006 07:39
http://lslwiki.com/lslwiki/wakka.php?wakka=moving_start is whatcha want.
_____________________
Elsewhere Essex
Registered User
Join date: 8 Sep 2006
Posts: 50
12-14-2006 07:47
sensor polling is the only wa to detect avatar state as far as i know
another thing to keep in mind is that if they have run on, it's only useful as far as movement detection goes, if they are also walking. walking isn't replaced by running, it's added to it.
CODE

default {
state_entry() {
llSensorRepeat( "", "", AGENT, 96, TWO_PI, 0.25);
}

sensor(integer num_detected) {
integer i;
for (i = 0; i < num_detected; i++) {
if (llGetAgentInfo(llDetectedKey(i)) & AGENT_WALKING) {
if(llGetAgentInfo(llDetectedKey(i)) & AGENT_ALWAYS_RUN){
// they are running and actually moving;
// do something with that
}
else {
// they are walking
// do something with that
}
}
}
}
}
Dragon Eccleston
Registered User
Join date: 25 Dec 2005
Posts: 42
12-14-2006 09:53
moving_* events aren't overly reliable unfortunately. Try this:

CODE

default
{
moving_start()
{
llOwnerSay("move start");
}
moving_end()
{
llOwnerSay("move end");
}
}


You'll see that the movement events are fired repeatedly and seemingly randomly, and moving_end isn't always called
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
12-14-2006 10:15
If you're trying to detect voluntary movement only, you could take movement controls but also pass them through, then use the control() event.

An 0.2 second timer probably isn't causing much lag though, unless you're doing an awful lot every time it fires.
_____________________
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
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
12-14-2006 10:21
i would use llGetAgentInfo
http://lslwiki.com/lslwiki/wakka.php?wakka=llGetAgentInfo
ive used this for swimming and flying anims and
also use it for the sound on my flip flop shoes
-LW
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-14-2006 13:57
Welp, I have another prim that has a listen() event setup that is running its code when a HUD the ava wears fires certain data. I wanted to experiment and see if having 2 events, one to detect avatar movement and the other my listen() would give better performance than my .2 timer and the listen().