MoveToTarget Help?
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-23-2009 16:07
Having a really hard time with this.
I'm rezzing an object with 10 velocity the object contains this code
key target;
default { state_entry() { target = llGetOwner(); llSetTimerEvent(.2); }
timer(){ list details = llGetObjectDetails(target, ([OBJECT_POS])); vector position = llList2Vector(details, 0); llLookAt(position, 10, .1); llMoveToTarget(position, 1.5); } }
It fires out at 10 Velcity and then freezes and wont move anymore, but the rotation still works, the object is Physical.
|
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
|
12-23-2009 16:41
You might try, instead of llList2Vector, use (vector) llList2String.... if the list contains a vector but it's in string format, when you use llList2Vector, no matter what it is, it'll return a zero vector. It does this for a lot of other types too.
vector position = (vector) llList2String(details, 0);
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-23-2009 18:10
I think all you need to do is call llStopMoveToTarget() (and llStopLookAt() can't hurt, either) before you call llLookAt() and llMoveToTarget() again.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 02:48
still now working even with just llMoveToTarget and the stop.
it works once the person it's ment to follow moves again but while there still it wont move.
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-24-2009 03:25
Most odd. A prim containing key owner;
default { state_entry() { llSetStatus(STATUS_PHYSICS,TRUE); owner = llGetOwner(); llSetTimerEvent(0.2); }
timer(){ llStopLookAt(); llStopMoveToTarget(); list details = llGetObjectDetails(owner, ([OBJECT_POS])); vector position = llList2Vector(details, 0); llLookAt(position, 10, .1); llMoveToTarget(position, 1.5); } }
is following me around perfectly happily as I write this.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 03:38
Yeah so it must be something to do with my rezzer, whitch is no mod.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 03:49
Would there be another way to do the same thing llMovetoTarget does?
I've tried look at with local force/impulse, but it doesn't really work
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-24-2009 03:54
Oh.. I hadn't really taken on board that it's coming out of a rezzer. Try resetting the script on_rez to make sure state_entry() happens. Or move the stuff that's currently in state_entry into the on_rez event. See if that helps.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 04:26
all thats happening fine, I'm really struggling, even when I put it in a different rezzer it works.
it just freezes mid air
Even when I make the rezzing syntax the same, the diferent rezzers one works, one causes the freeze.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 04:39
The only option I think I have is to do it without llMoveToTarget but I don't think that's going to be easy
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-24-2009 05:29
I really don't think that's the issue, Nyx. I've just added on_rez(integer p){ llResetScript(); }
to the script i posted above, and put the object in a rezzer with this script string contents; default { state_entry() { contents = llGetInventoryName(INVENTORY_OBJECT,0); }
touch_start(integer total_number) { llRezAtRoot(contents, llDetectedPos(0 ) + < 6.0, 0.0, 0.0 > * llDetectedRot( 0 ), ZERO_VECTOR,llGetRot(),0); } changed(integer change){ if(change&CHANGED_INVENTORY){ llResetScript(); } } }
and it works perfectly.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 05:36
the code goes in a vehicle and once it's in their i get the problem thrown up.
I'm wonderingif I could turn the object into a vehicle and do it that way
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-24-2009 05:58
Ah, well the fact it's a vehicle makes a bit of difference, i think.
I can't quite visualise what you're trying to do, but assuming you want to rez a vehicle that follows you round till you get on it and drive it, why not try making it start off as an ordinary object and only become a vehicle -- by setting the appropriate flags -- when you sit on it?
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 06:08
I dont need to drive it, it just need to follow someone after leaving a vehicle, but since llMoveToTarget doesn't work I need another way.
Heres final llMoveToTarget try:
Object Rezzed:
default { on_rez(integer unused){ llResetScript(); } state_entry() { llSetBuoyancy(.9); llSetTimerEvent(1);
} timer(){ list details = llGetObjectDetails(llGetOwner(), ([OBJECT_POS])); vector position = llList2Vector(details, 0); llMoveToTarget(position, 1.5); }
}
Rezz Script
llRezObject("object to rez", llGetPos()+<3,0,0>*llGetRot(), <5,0,0>, ZERO_ROTATION, 0);
--
Shot from a vechicle in motion, moves a little, stops dead and refuses to move unless llGetOwner() moves around for awhile.
--
Any ideas on fixing this, or a work around not using llMoveToTarget would be very very helpful
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
12-24-2009 06:39
How far does the rezzed object need to travel, when it is rezzed from the vehicle? llMoveToTarget will fail if you ask it to go 65 meters or more. You can still use it if you chop your movement into smaller segments, or use llApplyImpulse or something to get roughly there and llMoveToTarget for the last leg.
|
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
|
12-24-2009 07:01
what! Yeah that would proberly be it. Why doesn't the Wiki or anywhere else mention that? I can just send it to half way between then all the way, if the 65 meters this is the case. Thanks Viktoria http://wiki.secondlife.com/wiki/LlMoveToTarget
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
12-24-2009 07:18
I would not use llMoveToTarget() with the vehicle system active. They use two different sets of algorithms to operate physically, and can conflict. If you must use llMoveToTarget(), turn off the Vehicle system beforehand and, as Viktoria says, llMoveToTarget() will silently fail to move on any distance 65m or greater.
(the 65m limit is in both wikis, btw)
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
12-24-2009 07:29
The 65m thing was missing from the "new" wiki but it's there now.
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
12-24-2009 07:44
Ahh. Good deal, then. 
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
12-24-2009 21:58
You're triggering the timer event ever .2 seconds, yet, your tau in llMoveToTarget() is 1.5 seconds??? I think you may need to understand llMoveToTarget() a bit better. What exactly are you trying to do, and why do you need to call the timer event every .2 seconds? Why not just set a target (llTarget()) and process using the at_target() and not_at_target() events? Maybe if you describe what you're trying to do I could help out. The code you have listed makes no sense, and doesn't surprise me that it's freezing the object. If a vehicle is rezzing the object that's no big deal, weather the rezzing object is physical or not makes no difference. Also, why are you rezzing the object with a velocity to begin with if you're moving to a target .2 seconds later? Like I said, I don't think you fully understand llMoveToTarget very well. vector offset = < -1, 0, 1>; //1 meter behind and 1 meter above owner's center. default { state_entry() { llSetStatus(STATUS_PHYSICS, TRUE); // Little pause to allow server to make potentially large linked object physical. llSleep(0.1); llSetTimerEvent(1.0); } timer() { list det = llGetObjectDetails(llGetOwner(),[OBJECT_POS,OBJECT_ROT]);//this will never fail less owner is not in the same sim // Owner detected... // Get position and rotation vector pos = llList2Vector(det,0); rotation rot = (rotation)llList2String(det,1); // Offset back one metre in X and up one metre in Z based on world coordinates. // use whatever offset you want. vector worldOffset = offset; // Offset relative to owner needs a quaternion. vector avOffset = offset * rot; pos += avOffset; // use the one you want, world or relative to AV. llMoveToTarget(pos,0.4); } }
Wouldn't this do the trick?
|