|
2 registered members (steyr, alibaba),
534
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
weird c_trace behaviour...
#347435
11/15/10 13:27
11/15/10 13:27
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
OP
Senior Expert
|
OP
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
I have an entity that is placed before a c_trace call and afterwards I move it somewhere else so it cannot be hit by the trace. The problem is, c_trace does not know that the entity is there when I don't use a "wait(1);" after placing the obstacle. Without wait: With wait:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
void main() {
video_mode = 11;
fps_max = 60;
level_load(NULL);
camera.x = -100;
player = ent_create(CUBE_MDL,nullvector,NULL);
set(player,POLYGON);
wait(1);
c_setminmax(player);
while(1) {
player.y = 0;
//wait(1); // <------------ !!
c_trace(vector(0,0,32),vector(0,0,-32),IGNORE_PASSABLE);
player.y = 32;
draw_line3d(vector(0,0,32),NULL,100);
if(trace_hit) {
draw_line3d(vector(0,0,32),COLOR_RED,100);
draw_line3d(vector(0,0,-32),COLOR_RED,100);
}
else {
draw_line3d(vector(0,0,32),COLOR_GREEN,100);
draw_line3d(vector(0,0,-32),COLOR_GREEN,100);
}
wait(1);
}
}
What's wrong? Thanks in advance!
"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: weird c_trace behaviour...
[Re: Superku]
#347482
11/15/10 16:15
11/15/10 16:15
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
I don't see why that would be "weird behavior", seems more like working as intended.
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: weird c_trace behaviour...
[Re: Superku]
#347484
11/15/10 16:26
11/15/10 16:26
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
as long as you don't move it at super high speeds, that wouldn't be the case
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: weird c_trace behaviour...
[Re: Michael_Schwarz]
#347486
11/15/10 16:38
11/15/10 16:38
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
OP
Senior Expert
|
OP
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
as long as you don't move it at super high speeds, that wouldn't be the case No, there are several issues, not just that stupid example. Take a platform that moves vertically up (or down). Because the collision hull is not updated immediately, the player's gravity-trace will take the old position into account and thus he will sink into that platform (one-frame-lag) or float above it, when the platform moves down (I know some workarounds, of course). I'm currently writing a hitbox code where my player-shoot function c_traces for enemies. If some enemy is hit, the hitboxes are placed and a short range c_trace (which now ignores enemies) detects which box has been hit. That does not work without a wait, because of the aforesaid reason.
Last edited by Superku; 11/15/10 16:39.
"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: weird c_trace behaviour...
[Re: bart_the_13th]
#347542
11/16/10 03:50
11/16/10 03:50
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
I guess there's a lot of internal stuff done during a wait. Perhaps a c_move would ensure it all got updated? The function should be efficient enough that with IGNORE_WORLD | IGNORE_MAPS | IGNORE_SPRITES it wouldn't be wasteful. It's just a matter of whether or not it works...
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: weird c_trace behaviour...
[Re: JibbSmart]
#347698
11/17/10 22:34
11/17/10 22:34
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
OP
Senior Expert
|
OP
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Perhaps a c_move would ensure it all got updated? Thanks Julz, you helped me out... again!
"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: weird c_trace behaviour...
[Re: Superku]
#347752
11/18/10 16:15
11/18/10 16:15
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Oh, haha  That was lucky. It was just a guess. I'm glad it works!
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|