[Scripting] problem, angular Velocity weirdness. script vs properties


Playing with angularVelocity, now my problem, is that the numbers you use in edit entity properties is not the same as the same number in script. :confused:

I want this, works perfect as test when you do it in the properties.

But as soon i do the same with a script.

            angularVelocity: {x:0,y:0,z:90},
            angularDamping: 0.400,
            velocity: {x:0,y:0,z:0},
            gravity: {x:0,y:0,z:0},
            acceleration: {x:0,y:0,z:0},            
            damping: 0.39,
            restitution: 0.5,
            friction: 0.5,
            density :1000,
            gravity: {x:0,y:0,z:0},
            acceleration: {x:0,y:0,z:0},

Things go coo,coo. Yes i did tried it with less parameters first. mabye where missing something but i think i have now add all. and it still start to rotate like crazy with wrong parameter

Now i don’t see what is going wrong and why 90 Roll in script is not the same as 90 in properties.


Angular velocity is a quaternion when it is set to the object. Youll have to run it through




neither Linear nor Angular Velocity seem to hold consistent values, Angular Velocity has been busted for weeks and if you accidentally change a field value for Linear Velocity - the new value is applied immediately and object is moved and often lost in deep space


The changing value is due to the Damping values taking immediately effect when the values are set. The Angular Damping and the Linear Damping both effect the speed at which the velocities. They will fade the value off per sec.

Atleast the stuff I set spinning, are still spinning at a constant rate since I created them about 4 months back.


yes, these values are at a much lower level than what you see in SL (totally fine with that). if you want to make something rotate permanently, set the angular dampening to 0 first, then set the angular velocity.


So far it works now for me. But i still think that im missing some logic.

I would say if you want to rotate a entity 90 degree. you put 90 in some field.
Then high fidelity knows the prim need to stop at 90. and start to calculate when the friction need to kick in. But how it now look;s you need to add 115 to make a 90 degree rotation with smooth stop. So the parameters are not really logic for me for what the give as result.

This my test setup. for now


hmm, maybe I am misunderstanding what you are trying to do. Are you wanting to set the rotation of an entity to a specific angle? If so, then just set the rotation property.

Are you wanting to make an entity rotate itself to a specific rotation, where you will see that rotation happen smoothly? If so, then you need to script that behavior by getting its current rotation, getting the rotation vector between the current rotation and target (desired) rotation, then applying an angular velocity, or some fraction depending on how long you want the rotation to take, to the entity using that between vector, monitoring the rotation as it progresses. Then when the rotation is close enough to the target, zero the angular velocity, hard set the rotation.


I ran into this issue some months ago, its not a bug its a change. Angular velocity is noted in radians.

Simply put, the figures you put into the edit window are in degrees, but the figures you put into a script must be radians, you have to convert your degrees to radians and thats what you enter into the script.

radians = degrees /57.3
if you want 90degrees, input 1.57 into angular velocity (and dont forget to zero the angular damping or it will quickly stop)
BTW thats degrees/radians per second, the thing will take 4 seconds to revolve.



Maybe this is what Balzy said, if you just want it to “be rotated” 90deg then you want Rotation not angular velocity, and as Menithal points out rotation is in quaternians.


BTW, it is not uncommon, and indeed, SL does it this way that the UI entry is in degrees but that the scripted methods use radians.


Sorry Richo, I didnt read this properly now I understand the movement you want.
You are doing it right with adding damping.
But it wont stop at a given angle, it will turn constantly at the given speed and be slowed by the damping but I’m not sure what the math is for working out the rate of slowing from a given damping and I’m really not sure how to make it stop at a specific orientation.
Lots of trial and error to be had, unless someone can explain the damping factor more clearly.


Digging from the Entity files, we have this info:

Line 501:

    // NOTE: Damping is applied like this:  v *= pow(1 - damping, dt)
    // Hence the damping coefficient must range from 0 (no damping) to 1 (immediate stop).
    // Each damping value relates to a corresponding exponential decay timescale as follows:
    // timescale = -1 / ln(1 - damping)
    // damping = 1 - exp(-1 / timescale)


What i do is, rotate object smooth to some angle. then it need to stop smooth.

I now convert degree to radians with the command. Quat.fromPitchYawRollDegrees(0,0,90). but 90 is the wrong number. it need to be a bit higher.

i solved te problem by trail and error. Until the day i can go up one level in math :open_mouth:

Start simple, the script i make is pretty sure much better then the one from long ago. Understand how high fidelity thinks is most important first step with scripting.

and menithals formule i need to study because that going to be usefull anyway.


Yes, that is standard exponential damping. Very nice to see it implemented here,


It would be very nice to have a function that get triggered when the entity stops moving. Would make things so much more easy.