Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Calculating speed in m/sec

Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
03-27-2006 20:57
If what I want to know is absolute ground speed and I use the values from llGetVel() which for example were <3.0. 4.0, 0.0>. Would I be correct that my speed is 5m/sec.? Right or wrong, how could I write the correct calculation in a script?

Thanks, Mod
Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
03-27-2006 21:15
llVecMag(llGetVel()) will tell you your speed.
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Still not there
03-28-2006 01:09
In a stationarly prim llVecMag(llGetVel()) comes out at <0.0, 0.0, 0.0>. Though I easly undersand that speed is 0, what I am looking for is one number that represents m/sec.

Mod
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-28-2006 01:19
llVecMag should return a float not a vector. I can't get in world atm but see no reason to doubt your data - bug report it, it's definitely not working as advertised.
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Test
03-28-2006 03:14
I did the following test:
float x = llVecMag(llGetVel()));
llOwnerSay((string) x);
and got "<0.0, 0.0, 0.0>"
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-28-2006 04:05
Uh, if that's happening, that's an immensely serious bug (which wasn't present when I was on a few hours ago). A float should never come out as a vector. Can you post up your whole test script?
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
03-28-2006 04:18
CODE
default
{
state_entry()
{
float x = llVecMag(llGetVel());
llOwnerSay((string) x);
}
}


Object: 0.000000


seems fine to me.
_____________________
Geometry is music frozen...
Paul Churchill
Pie are squared
Join date: 8 Sep 2005
Posts: 53
03-28-2006 05:43
From: Laukosargas Svarog
CODE
default
{
state_entry()
{
float x = llVecMag(llGetVel());
llOwnerSay((string) x);
}
}


Object: 0.000000


seems fine to me.


Just popped In World. llVecMag(llGetVel()) is definitely returning a float.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
03-28-2006 09:52
Maybe you did llVecNorm(llGetVel()) instead?
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Here is the complete code
03-28-2006 12:33
default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
//vector vel = llGetVel();
float speed = llVecMag(vel);
//llVecMag(llGetVel());
float x = llVecMag(llGetVel());
llOwnerSay((string) x);
}
}
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Here is the code
03-28-2006 12:39
I had to be away for a few hours but just went back in copied the code below usuing cut and paste
default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
//vector vel = llGetVel();
float speed = llVecMag(vel);
//llVecMag(llGetVel());
float x = llVecMag(llGetVel());
llOwnerSay((string) x);
}
}

Still get the answer <0,0,0>
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
03-28-2006 14:30
Whatever was the problem, it has corrected itself.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-28-2006 14:43
From: Mod Faulkner
I had to be away for a few hours but just went back in copied the code below usuing cut and paste
default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
//vector vel = llGetVel();
float speed = llVecMag(vel);
//llVecMag(llGetVel());
float x = llVecMag(llGetVel());
llOwnerSay((string) x);
}
}

Still get the answer <0,0,0>

Well, that wouldn't compile in the first place. Line 3 of the touch_start() is referring to a variable that doesn't exist, because its declaration has been commented out.
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Thanks
03-28-2006 14:47
I am sure I messed it up, but thanks to every on for attempting to help.

MOD
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Embarrassed
03-29-2006 01:59
I want to apologize to everyone who spend time try to help with this problem. I finally discovered that I has a second script that was running and was sending the response. I should have checked for this before posting my question. I will attempt to avoid embarrassing myself and wasting your time in the future.

Mod