Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Is there a way to...

Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
07-17-2005 17:33
I want to create real moving wheels. (not just the texture rotating trick)

Is there a way to take a wheel that is already linked to a car and write a script that can do this.

When the car is moving forward, it will...

1.) get the velocity of the car
2.) translate the velocity into an object rotation speed
3.) rotate the object at that speed
4.) keep doing this constantly so that it stays with the changes of velocity.

Something kinda similar to the texture rotating trick here.

CODE

default
{
state_entry()
{
llSetTimerEvent(0.20);
}
timer()
{
vector vel = llGetVel();
float speed = llVecMag(vel);
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP | REVERSE, 0, 0, 0, 0, 1, speed*0.5);

}
}
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
07-17-2005 18:36
You can use llTargetOmega on child prims of a linked object, but the result may not totally be satisfactory, in that the resulting object can't be physical. I'd do it with textures, as you described.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
07-17-2005 19:05
The only problem with that is when I go in reverse, the textures spin forward. It looks weird.
Aliasi Stonebender
Return of Catbread
Join date: 30 Jan 2005
Posts: 1,858
07-17-2005 19:16
From: Kwipper Manimal
The only problem with that is when I go in reverse, the textures spin forward. It looks weird.


Why not reverse the way the texture rotates, then?
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
07-17-2005 20:47
From: Aliasi Stonebender
Why not reverse the way the texture rotates, then?

Indeed. There's even a constant for it.

http://secondlife.com/badgeo/wakka.php?wakka=llSetTextureAnim

From: someone
...
REVERSE animate in the reverse direction
...
_____________________
---
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
07-17-2005 21:22
From: Kwipper Manimal
The only problem with that is when I go in reverse, the textures spin forward. It looks weird.



It sounds like he was talking about the suggestion to use llTargetOmega
_____________________
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
07-17-2005 21:24
Perhaps. But then again, this situation seems to be tailor-made for llSetTextureAnim. Most vehicles I see with spinning wheels use a combination of that and llSetRot for moving about.
_____________________
---
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-17-2005 21:51
From: Jeffrey Gomez
Perhaps. But then again, this situation seems to be tailor-made for llSetTextureAnim. Most vehicles I see with spinning wheels use a combination of that and llSetRot for moving about.

I agree with Jeff here. Using llSetRot for creating a "spinning wheels" effect will look much less appealing then one with llSetTextureAnim (alot choppier), and it will generate many more object updates then are neceessary (llSetTextureAnim causes 1 update for every call, even when the anim is playing, whereas if you use llSetRot for this, youll need to call it very often, thus generating a significant number of partial updates.) llSetRot should be used to simulate the wheels effect when the car is turning left and right, and llSetTextureAnim the wheels spinning.
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
07-18-2005 02:40
From: Jeffrey Gomez
Perhaps. But then again, this situation seems to be tailor-made for llSetTextureAnim. Most vehicles I see with spinning wheels use a combination of that and llSetRot for moving about.


I agree 100%.

But, if you do want to use llTargetOmega, read this

a link to that thread can also be found in the comments of llTargetOmega in the LSL WIKI

but even llTargetOmega is a "trick" (client-side) instead of real rotation of the physical object
_____________________
Rayve Mendicant
Scripts for L$5 billion
Join date: 12 Mar 2005
Posts: 90
07-18-2005 15:30
Been dealing with rotations a lot with a couple of my new games. Biggest problem with the rotating textures is it's all client-side so it may appear different to multiple ppl. Tihs may nto be important with tires, but good to know.

If it is important, this can be dealt with my llTextureAnimation() followed with an llSetRot() at the end to set the object to the correct resting rotation.

This works smoother than it may seem it would. I use this method on my slot machine and looks very realistic.

Since there is no way to physically rotate with llSetRot() without using a PWM type motor and this method results in very unsmooth stepping, I'd abandon the idea.

If someone has a way to use llSetRot() alone to smoothly rotate an object and I've jsut missed a method, please let us know :).
_____________________
_______________________

Rayve Mendicant
Second Evolution

"Darwin ain't got nothin' on this"