Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Newbie
IchMagMeinenBoxster  Offline 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
T
Tempelbauer Offline
Expert
Tempelbauer  Offline
Expert
T

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
W
Wicht Offline
User
Wicht  Offline
User
W

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: Wicht] #176175
01/03/08 16:08
01/03/08 16:08
Joined: Sep 2003
Posts: 8
Frankfurt, Germany
IchMagMeinenBoxster Offline OP
Newbie
IchMagMeinenBoxster  Offline OP
Newbie

Joined: Sep 2003
Posts: 8
Frankfurt, Germany
Hallo,

danke für die Tips, leider funktioniert es nach wie vor nicht, wie es sollte.

Ein Fehler war reine Dummheit meinerseits, hatte tatsächlich vergessen, das ganze in einer Schleife laufen zu lassen. Auch das ich hier "invisible" benutzen sollte, wusste ich nicht. ABER ...

Jetzt sind die Objekte STÄNDIG unsichtbar, auch wenn sie definitv in der Kamera zu sehen sind. Wisst ihr hier noch Rat ?

Danke schonmal/nochmal.

Gruss
Thomas

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
W
Wicht Offline
User
Wicht  Offline
User
W

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
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

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.
Re: What's wrong with ths script ? - Toggle Visibi [Re: Fenriswolf] #176178
01/03/08 23:32
01/03/08 23:32
Joined: Sep 2003
Posts: 8
Frankfurt, Germany
IchMagMeinenBoxster Offline OP
Newbie
IchMagMeinenBoxster  Offline OP
Newbie

Joined: Sep 2003
Posts: 8
Frankfurt, Germany
Hallo,

vielen Dank für eure Hilfe !

Funktionieren tut das ganze jetzt, allerdings habe ich aufgrund der Grösse einiger Objekte und der Kamera-Einstellung (Sicht von schräg-oben) übelstes Clipping.

Aber trotzdem vielen Dank !

Gruss
Thomas


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1