Change font size
It is currently Fri Sep 10, 2010 12:08 am

Forum rules


Image



Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: Question about using "llsetpos"
PostPosted: Sat Aug 07, 2010 6:18 am 

Joined: Mon Aug 02, 2010 11:09 pm
Posts: 4
My goal is to make a non physical train that moves on a fixed route using llsetpos, but I have no idea how the command is used to move objects like this. The train is not controlled by a user, it moves with an always running script. If anyone could give me a simple/sample script or tutorial, that would be wonderful.


Top
 Profile  
 
 Post subject: Re: Question about using "llsetpos"
PostPosted: Sat Aug 07, 2010 7:05 am 
User avatar

Joined: Mon Jul 05, 2010 7:10 pm
Posts: 3
Location: Staines, United Kingdom
Spot on the monorail system I've been working on. It relies on 10 meter long track pieces that are named simply "Track" to guide itself along them using a sensor. However there are major issues with this and monorail/train systems in general, as described below.

To explain briefly, what this code does is sense for any track pieces in front of it and then, using a for loop, move itself gently towards it. llSetPos works (as usually does in any case) by using llGetPos + final destination. In this case, it finds the distance between it's current position and the next track piece, divides that by 4 steps and then adds that division to it's current position. Half way through it sets it's rotation to that of the track piece.

Code:
vector      m_NEXTPOS;
vector      m_NEXTFWD;
rotation    m_NEXTROT;
integer     m_STEPS = 4;

motionTo(vector dest,rotation rot) {
    integer i;
    vector currentpos   = llGetPos();
    vector step         = (dest - currentpos) / m_STEPS;
   
    for (i = 1;i <= m_STEPS; i++) {
       
        if (i == (m_STEPS / 2)) {
            llSetRot(rot);
        }
       
        llSetPos(currentpos + (step * i));;
    }
}

default {
    state_entry()    {
        llSensorRepeat("Track",NULL_KEY,PASSIVE,10,PI/4,1);
    }
   
    sensor(integer n) {
        m_NEXTPOS = llDetectedPos(0);
        m_NEXTROT = llDetectedRot(0);
        m_NEXTFWD = llRot2Fwd(m_NEXTROT) / 10;
       
        motionTo(m_NEXTPOS + m_NEXTFWD,m_NEXTROT);
    }
}


Incomplete code as it does not make any stops or anything. Easily done with different names of track I guess.

However, this and any other method of train/monorail (physical or nonphysical) does NOT WORK cross region, which limits your train system to just one region. llSetPos fails silently when moving an object across a boundary and physical objects crossing are.. just a nightmare. The only possible solution to this is a megaregion but personally I do not recommend them as they are incomplete, lack parcel support, tend to break and are hell to teleport into.

Hope this all helps :U


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net