Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, juanex), 1,247 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_trace and level geometry detection? #303091
12/25/09 03:33
12/25/09 03:33
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
I set up movement code so that the player moves forward in increments of 256 quants. I'm trying to prevent movement altogether when c_trace recognizes a wall 128 quants away. The problem is that I don't know how to detect regular walls in c_trace. Code sample: c_trace (player, vector(player.x + 128, player.y, player.z), Use_Box > 0); // where "> 0" returns distance to player. if (hit.entity = NULL) {player.x = 0;} //end of code sample. I tried many variations on this code sample but none seem to work. Please help. If any further info needs to be provided, let me know. Thank you.

Re: c_trace and level geometry detection? [Re: SirCamaris] #303139
12/25/09 21:55
12/25/09 21:55
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Have a look at the syntax of c_trace in the manual.

c_trace (player.x, vector(player.x + 128, player.y, player.z),USE_BOX);
if(trace_hit) { don't move }
else { move }

To be on the safe side (the wall could be f.i. 128.1 quants away, depending on your movement code) you could increase the distance of your trace instruction. If c_trace hits something it will return the distance to the object/ wall.

result = c_trace (player.x, vector(player.x + 150, player.y, player.z),USE_BOX);
if(trace_hit && result < 129 or some other value) { don't move }
else { move }


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace and level geometry detection? [Re: Superku] #303210
12/26/09 20:40
12/26/09 20:40
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
Superku,
Thanks for the reply. When placing the mouse over c_trace in SED, it displayes info on how c_trace is used. It says that c_trace modifies trace_hit, where a value greater than zero is the c_trace distance from player to object. When I place the cursor over trace_dist after typing it in though, there is no description on how it is used, which leads me to believe that it is not being used when the code is executed. My question is if this variable is predefined, why wouldn't a description show on how to use it? Also, may this have something to do with me saving the document as .c instead of .wdl? Would trace_dist work in one over the other? Thank You.

Re: c_trace and level geometry detection? [Re: SirCamaris] #303216
12/26/09 21:55
12/26/09 21:55
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Whether a description appears or not, that does not mean a thing.
After a trace instruction the variable trace_hit is 1 (something hit) or 0 (else), it is not set to different values than 1/0.
Have a look at the following example:

function a_useless_function {
// ...
return 523;
}


...
result = a_useless_function();
Now result is 523 and no predefined variable has been changed to return the value.
It is exactly the same with c_trace:
result = c_trace(some parameters);
or
var distance;
distance = c_trace(some parameters);.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace and level geometry detection? [Re: Superku] #303289
12/27/09 21:42
12/27/09 21:42
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
This is some of what I tried so far:

c_trace(player.x, vector(player.x + 128, player.y, player.z), IGNORE_ME);
if (trace_hit = 1)
{c_move(player, vector(0,0,0)nullvector, GLIDE);}
else {move_forward();}

trace_hit appears to be working because the coordinates that I put in reldist vector in c_move get executed. What is odd however, is that when the level starts, the first wall in front of the player is more than 256 quants away, so trace_hit should really be 0. I'm thinking this may have something to do model placement, although in Wed, the model is within the corridor and isn't touching anything.

Thank you again for your continued help.

Re: c_trace and level geometry detection? [Re: SirCamaris] #303293
12/27/09 22:11
12/27/09 22:11
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
well, if you don't program a side scroller, you must put the c_trace in the directio of the player:


c_trace(player.x, vector(player.x + 128*cos(player.pan)*cos(player.tilt), player.y+128*sin(player.pan)*cos(player.tilt), player.z+128*sin(player.tilt)), IGNORE_ME);

this should work laugh

Re: c_trace and level geometry detection? [Re: Rei_Ayanami] #304597
01/09/10 01:18
01/09/10 01:18
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
Thank you Rei; It took me a while to figure it out, but you are right. I needed to put c_trace in the direction of the player. The only other thing I had to add was USE_BOX.

Re: c_trace and level geometry detection? [Re: Superku] #304598
01/09/10 01:27
01/09/10 01:27
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
Superku

I was able to get c_trace to work properly by building on your and Rei's comments. Here is the final version:
Code:
if (c_trace (player.x, vector(player.x + 128*cos(player.pan), 
    player.y + 128*sin(player.pan), player.z + 0), IGNORE_ME | USE_BOX) > 0)
   {c_move (player, vector(0, 0, 0), nullvector, GLIDE);}
else
   {move_forward();}


Thanks again for your help.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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