[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - [FTE] .customphysics in CSCQ

[FTE] .customphysics in CSCQ

Discuss CSQC related programming.

Moderator: InsideQC Admins

[FTE] .customphysics in CSCQ

Postby toneddu2000 » Sat Jan 07, 2017 4:02 pm

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTE] .customphysics in CSCQ

Postby toneddu2000 » Sat Jan 07, 2017 4:45 pm

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTE] .customphysics in CSCQ

Postby Spike » Sun Jan 08, 2017 3:13 am

the .customphysics method completely replaces the logic normally performed according to the entity's movetype field.
be warned that this includes calling the think function.
movetypes being ignored means that the only friction, acceleration, and movement performed is that which you do yourself. So yes, you'll need to update both the velocity and origin.
tracebox will of course trace a box from a start position by some distance and tell you both where you hit and the angle(plane normal) of the surface that you hit. This provides you with a way to move your entity forwards, and to bounce or slide or whatever instead of re-impacting the surface the next frame too.
note that my code calls tracebox a few times between clipping the velocity. this ensures that the entity slides along cracks where multiple planes might be blocking the entity (especially if gravity is pushing you against them too).

using customphysics is NOT the same as custom prediction. custom prediction is quite specific in its needs, specifically, custom prediction needs to apply each input frame which is still pending to the player's entity, with the expectation that the next packet received from the server will snap it back again to where it used to be requiring you to reapply everything.
the only reason my csqc used an empty customphysics function was to ensure that the player's movetype_walk/etc value was ignored, so that the only thing affecting the player was the prediction code (unlike ssqc with its SV_RunClientCommand function, player entities are not special in csqc).
the prediction code needs to be shared between client and server, so that both are guarenteed to obtain the same results. The server's copy is run from SV_RunClientCommand, while the client's copy is re-run for each pending input frame. This means that the code CANNOT use time or even frametime, but MUST use input_* as the only inputs beyond those fields which you're networking (like velocity and origin). Even the use of tracebox can result in prediction misses (as it depends on the position+size+etc of other entities), but you should normally be able to get away with it when other entities are not moving around too much (unless you were somehow predicting those too, which gets really really messy), the problem comes when prediction misses are present in every single packet, those are the ones that will result in significant problems (read: juddering, whereas snapping is easier to hide).
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: [FTE] .customphysics in CSCQ

Postby toneddu2000 » Sun Jan 08, 2017 4:36 pm

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTE] .customphysics in CSCQ

Postby Spike » Sun Jan 08, 2017 8:00 pm

when I said that customphysics replaced logic including think functions, what I meant was that think functions on the entity will no longer happen, meaning you need to call them yourself if you still want them to happen.

trace_fraction not resetting:
not entirely sure what you mean. note that tracebox does NOT bounce or slide itself. if your start position is directly next to a wall or something and the direction that the box is traced in points even slightly towards that wall, then the tracebox will of course hit that wall instantly, making no progress.
you MUST clip/bounce the velocity according to the trace_plane_normal value reported by tracebox.
velocity += -1 * dot(velocity, trace_plane_normal) * trace_plane_normal;
the dot says how fast the velocity is travelling towards the plane, the negate swaps the direction, and the multiply pushes it away in the correct direction.
scale it by 2 and the player will bounce instead (quake's grenades use 1.5, allowing them to lose momentum).
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: [FTE] .customphysics in CSCQ

Postby toneddu2000 » Mon Jan 09, 2017 9:18 am

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTE] .customphysics in CSCQ

Postby Spike » Mon Jan 09, 2017 11:02 am

if you ever did integrals in maths, then you should recognise speed(read: 1d velocity) as a line on a graph against time, and the distance travelled(read: 1d origin) as the area under it. the only real difference from highschool is that your velocity is known/relevant only for a really small time interval, and of course that walls might block you...
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: [FTE] .customphysics in CSCQ

Postby toneddu2000 » Mon Jan 09, 2017 9:15 pm

ok, let's take my old dusty math books out! :biggrin:
Thanks Spike, I'll post every update here.
First step is now create traceline / tracebox debug visual helpers. I should have done ages ago...
- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy


Return to CSQC Programming

Who is online

Users browsing this forum: No registered users and 1 guest