Jump to content

Trying to move object


ZachMatheson
 Share

You are about to reply to a thread that has been inactive for 2740 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi Team,

Below is the code I am trying to run in order to move an item between -1.0 and 1.0 metre on the X axis.

I have tried many methods with this being my final shot. when the object teleports it is not behaving.

 

state invisible {
state_entry()
{
vector currentPos = llGetLocalPos();
integer teleportRandomX = (integer)((integer)llFrand(1.0 + -1.0));
integer teleportRandomY = (integer)((integer)llFrand(1.0 + -1.0));
if (currentPos != spawnPos) {
llSetPos(spawnPos);
llSetPos(llGetPos()+<teleportRandomX,0,0>);
llSay(0,(string)llGetPos());
} else {
llSetPos(llGetPos()+<teleportRandomX,0,0>);
llSay(0,(string)llGetPos());
}
}

For instance my last try it started at <96.10229, 183.59870, 20.46061> and moved to <91.48725, 174.78190, 20.36469> which is not just -1.0 to 1.0 on the X-axis but the Y-axis is being manipulated to - just not by me.

Is there anything I should be looking for?

Link to comment
Share on other sites

This script will always try to move the object to spawnPos, whatever that is. It probably can't get all the way there, though, because llSetPos() only moves a maximum of 10m.

Also, take a look at what's happening with the llFrand() call. It will always be called with 0.0, the value of (1.0 + -1.0), which is not going to give you the results you want (and casting the results to integer is not going to help either).

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2740 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...