イベント:at_target
at_target(integer tnum, vector targetpos, vector ourpos)
この
イベントは変数targetpos(これはllTarget()関数の呼び出しによって定義されます。)で設定された目標地点の範囲にオブジェクトが入ってきたときに発生します。
変数tnumのパラメーターは到達済みの対象の(llTarget()関数の戻り値としての)ハンドル番号です。
複数の対象がアクティブになっているときにはこの値を調べてください。
変数targetposのパラメーターには設定された目的地点が与えられます。
変数ourposのパラメーターはllTarget()の中で指定された範囲内であればどこであってもオブジェクトの現在の位置が与えられています。
#つまり、目標地点と実際のこのイベントが発生する位置が同じ場所である保証はありません。
以下の例は関数lltarget()と付帯するイベントハンドラの使用例のデモンストレーションです。
この例がllMoveToTarget関数とllStopMoveToTarget関数を使用する必要性がない点に注意してください。
物を「編集」などで目標の範囲内に入るように動かすだけでもat_targetイベントは発生します。
翻訳者注
llTarget()と「[[not_at_target]]()やat_target()」イベントの関係は
llListen()関数とListenイベントの関係に類似する。
llMoveToTarget関数とllStopMoveToTarget関数は
「not_at_target()やat_target()」イベントの発生に直接関係しないこと
に十分注意するように。
integer targetID;
default()
{
[[touch_start]]( integer total_number )
{
// Become a physical object
llSetStatus(STATUS_PHYSICS, TRUE);
llWhisper( 0, "we're on our way" );
// destination is ten meters above our current positio
vector destination = llGetPos() + <0, 0, 10>;
// how close is close enough
float range = 0.5;
// Ask to be informed whether we're there or not
targetID = llTarget( destination, range );
// Start moving towards the destination
llMoveToTarget( destination, 10 );
}
not_at_target()
{
// We're not there yet.
llWhisper(0, "Still going");
}
at_target( integer number, vector targetpos, vector ourpos )
{
llSay(0, "We've arrived!");
// Stop notifications of being there or not
llTargetRemove(targetID);
// Stop moving towards the destination
llStopMoveToTarget();
// Become non-physical
llSetStatus(STATUS_PHYSICS, FALSE);
}
}
最終更新2008/02/8 by CrystalR Runo@SecondLife
最終更新:2008年05月07日 12:23