Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

object Movement

Serina Darkholme
Registered User
Join date: 11 Jan 2005
Posts: 35
02-04-2005 11:19
ok, i've look through this forum and the wiki several time and im afraid im just thick :(

heres what i want,

a script to keep an object moving forward, unless i hit something, in which case go back a bit, turning for a bit, then continue forward.

you know the one, all toy robots and maze-solvy things have it :)

ive tried and tried , but as LSL novice, i havent even got a clue about the moving, let alone the logic.

please can someone help me.

thanks.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
02-04-2005 12:38
Here's an example (I cant provide more help atm, kinda short on time):

CODE

float SPEED = 10;
collision_start(integer numColliders) {
// Vector pointing from this object to the object
// being collided with. You can think of it like an arrow.
vector offset = llDetectedPos(0) - llGetPos();

offset = llVecNorm(offset); // Normalize, we dont care about
// How "big" the arrow is (magnitude), just the way its pointing.

// Reverse the direction of the vector, making
// it point away from the object being collided with.
offset *= -1;

// Make the arrow "flat", we only want it to affect this object
// on the x and y axes.
// We dont want to change the object's height.
offset.z = 0;
// of course, now it wont help us when colliding with ceilings
// comment the above line out if you do want it to.

// Push the object in the direction of the arrow.
// We subtract the current velocity, because
// the collision would have already flung the object with
// some force. The subtraction makes it so that the only
// velocity the object has is due to the impulse we apply here.
llApplyImpulse((offset * speed * llGetMass()) - llGetVel(), FALSE);
}
}

==Chris
Serina Darkholme
Registered User
Join date: 11 Jan 2005
Posts: 35
02-04-2005 15:30
thanks, will give it a try :)