|
|
What's wrong with ths script ? - Toggle Visibility
#176172
01/03/08 13:43
01/03/08 13:43
|
Joined: Sep 2003
Posts: 8 Frankfurt, Germany
IchMagMeinenBoxster
OP
Newbie
|
OP
Newbie
Joined: Sep 2003
Posts: 8
Frankfurt, Germany
|
Hi there, could anybody please tell me what's wrong with this code ? Code:
entity* Figure;
FUNCTION CheckVisible(WhichFigure){ figure = WhichFigure; if (rel_to_screen(figure.pos,camera) != 0) { figure.visible = ON; } else { figure.visible = OFF; } wait(1); } I want an entity which calls this funtion only to be visible when it is "seen" by the camera. I am calling it within an action by "CheckVisible(Me);". I think I am a little bit stupid here, but I really don't understand why this function will not run correctly. I am on A6.60 Com. Any help is greatly appreciated. Thanks in advance, Thomas Sturm
|
|
|
Re: What's wrong with ths script ? - Toggle Visibi
[Re: IchMagMeinenBoxster]
#176173
01/03/08 14:39
01/03/08 14:39
|
Joined: Feb 2005
Posts: 3,687 Hessen, Germany
Tempelbauer
Expert
|
Expert
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
|
moin deine aktion wird einmal ausgeführt, nach der zuweisung zur entity. da prüft sie ob das objekt in der camera zu sehn ist. das ist schwachsinn, weil wenn du genau diese action der entity zuweist, sie standardmäßig schon sichtbar ist  du müsstest sie unsichtbar erstellen, dann in einer schleife oder nem event abfragen ob die entity im bild ist. Code:
FUNCTION CheckVisible(WhichFigure){ my.visible=off; figure = WhichFigure; while(1) { if (rel_to_screen(figure.pos,camera) != 0) { figure.visible = on; } else { figure.visible = off; } wait(1); } }
ich hoffe das funktioniert so, habs nicht getestet
|
|
|
Re: What's wrong with ths script ? - Toggle Visibi
[Re: Tempelbauer]
#176174
01/03/08 15:57
01/03/08 15:57
|
Joined: Sep 2005
Posts: 980 Aue, Sachsen, Germany
Wicht
User
|
User
Joined: Sep 2005
Posts: 980
Aue, Sachsen, Germany
|
Das sollte eigentlich funktionieren. Man braucht dazu keine separate Funktion. Achte bitte auf "visible" und "invisible"!!! Code:
action MyEntity { while(1) { if (rel_to_screen(my.pos,camera) != 0) { my.invisible = off; } else { my.invisible = on; }
wait(1); } }
|
|
|
Re: What's wrong with ths script ? - Toggle Visibi
[Re: IchMagMeinenBoxster]
#176176
01/03/08 16:31
01/03/08 16:31
|
Joined: Sep 2005
Posts: 980 Aue, Sachsen, Germany
Wicht
User
|
User
Joined: Sep 2005
Posts: 980
Aue, Sachsen, Germany
|
Jetzt geht's... Achte auf vec_to_screen (nicht rel_to_screen) und auf mypos statt auf my.pos. Code:
var mypos[3]; action MyEntity { while(1) { vec_set(mypos, my.x); // falls sich das Objekt selbst bewegen sollte if (vec_to_screen(mypos,camera) != NULL) { my.invisible = off; } else { my.invisible = on; }
wait(1); } }
|
|
|
Re: What's wrong with ths script ? - Toggle Visibi
[Re: Wicht]
#176177
01/03/08 16:53
01/03/08 16:53
|
Joined: Jan 2007
Posts: 221
Fenriswolf
Member
|
Member
Joined: Jan 2007
Posts: 221
|
Wenn du prüfen willst, ob eine Entity auf dem Bildschirm sichtbar ist, könntest du auch ihr clipped-Flag benutzen.
if (my.clipped) { // wenn nicht sichtbar ... } else { ... }
Last edited by Fenriswolf; 01/03/08 16:54.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|