ZachMatheson Posted October 22, 2016 Share Posted October 22, 2016 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 More sharing options...
Qie Niangao Posted October 22, 2016 Share Posted October 22, 2016 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). 1 Link to comment Share on other sites More sharing options...
ZachMatheson Posted October 23, 2016 Author Share Posted October 23, 2016 Hi Qie, Yes, it has a default location "spawnPos" which my object moves to by default which keeps an anchor center point then it moves between -1.0 to 1.0m metres on X. I will re-evaluate my Frand call, cheers. Link to comment Share on other sites More sharing options...
Recommended Posts
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