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
2 registered members (steyr, alibaba), 534 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
weird c_trace behaviour... #347435
11/15/10 13:27
11/15/10 13:27
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline 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:



Code:
///////////////////////////////
#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 Offline
Senior Expert
Michael_Schwarz  Offline
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: Michael_Schwarz] #347483
11/15/10 16:24
11/15/10 16:24
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Because c_trace should take the current situation into account, shouldn't it? Otherwise, when I move several objects within only one function, the collision behaviour would be wrong (i.e. move a platform first so it is below the player, but as the "collision hull" would stay at the old position, the player's gravity-trace would not detect it and thus the player would fall into some pits below).


"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] #347484
11/15/10 16:26
11/15/10 16:26
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
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 Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
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: Superku] #347541
11/16/10 03:28
11/16/10 03:28
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
Well, you can move the checking to be after/below the wait(1) statement.
Then use another variable to keep the c_trace result instead of using trace_hit

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
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

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 Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
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
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Oh, haha laugh That was lucky. It was just a guess. I'm glad it works!


Formerly known as JulzMighty.
I made KarBOOM!

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