Bobbing Platform (The Hard Question)

Discuss programming in the QuakeC language.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Bobbing Platform (The Hard Question)

Post by Baker »

Let's say you have 3 or 4 platforms suspended in mid-air. Can they be made to bob via QuakeC? (func_platform_bobbing or whatever)

"Q3-style" item bobbing (like in ezQuake or JoeQuake, cl_bobbing 1) uses the sin function to alternate through values between 0 and 1 with a circular kind of momentum.

Code: Select all

ent->origin[2] += sin(bobjrotate / 90 * M_PI) * 5 + 5
But this is client-side visual and basically an "effect" like how backpacks spin.

QuakeC deals with velocity.

Can bobbing platforms that have a minor bob be created in QuakeC, and if so, how? This seems a little problematic because the velocity would need to constantly change.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

you'd need to step it or something.
calculate where it should be in 1/30th of a second or so and calculate the velocity required to put it there.

MOVETYPE_PUSH is special, nextthinks use self.ltime instead of time. you should avoid using setorigin directly on a MOVETYPE_PUSH object or it'll trap ents within.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

you can make bobbing platforms when mapping by making the brush a train i believe.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

ceriux wrote:you can make bobbing platforms when mapping by making the brush a train i believe.
moving platforms != bobbing platforms.

AFAIK you cannot have bobbing platforms with just vanilla QuakeC.

In engines like Darkplaces you at least have sqrt(), so theoretically you could try to implement it messing with the speed instead the origin directly (to avoid the problems Spike mentioned).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
OneManClan
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm
Contact:

Post by OneManClan »

frag.machine wrote:
ceriux wrote:you can make bobbing platforms when mapping by making the brush a train i believe.
moving platforms != bobbing platforms.

AFAIK you cannot have bobbing platforms with just vanilla QuakeC.

In engines like Darkplaces you at least have sqrt(), so theoretically you could try to implement it messing with the speed instead the origin directly (to avoid the problems Spike mentioned).
(Newbie) Q1: What is a 'bobbing' platform? Are we talking a bouncing up and down movement, or a 'pendulum' effect? Speaking of pendulums:

Q2: Has anyone ever created a pendulum effect in Quake? ie. an item hanging/suspended from a rope which can be pushed and made to swinging back and forth until it (eventually) stops in its original position?

Q3: What about this possibility: A player is using a grappling hook, and gets blasted by a rocket while moving 'down the line'. He then swings left and right (like a pendulum) with the whole 'hook chain' moving with him. The width, speed, and duration of the swinging depending on how long the line is, and/or how far he is from the end of the line. As a newb w embarrassingly minimal mathematical ability I assume this is horrendously complicated... is it?


OneManClan
ps I'm using a modified version of "Mike's" Morning Star hook.qc: http://pastebin.com/YnG1138L
Last edited by OneManClan on Tue May 17, 2011 1:58 am, edited 1 time in total.
Lardarse
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Re: Bobbing Platform (The Hard Question)

Post by Lardarse »

Baker wrote:Let's say you have 3 or 4 platforms suspended in mid-air. Can they be made to bob via QuakeC? (func_platform_bobbing or whatever)

"Q3-style" item bobbing (like in ezQuake or JoeQuake, cl_bobbing 1) uses the sin function to alternate through values between 0 and 1 with a circular kind of momentum.

Code: Select all

ent->origin[2] += sin(bobjrotate / 90 * M_PI) * 5 + 5
But this is client-side visual and basically an "effect" like how backpacks spin.

QuakeC deals with velocity.
You can make them bob, but they won't be that smooth. Basic idea is that the platform nextthinks a lot to adjust velocity. Not sure how you make sure it stops at exactly the correct top/bottom points every time, though.

Also, sin() can be emulated (without DP_QC_SINCOSSQRTPOW) with a well-placed call to makevectors() - see mathlib.qc for an explaination.
Roaming status: Testing and documentation
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

After reading the replies and considering this further. I think I know how to write this and it won't involve any sqrt or sin type of calculations (but will look like it did :D ). Will post a progs.dat and source if successful.

[If this works ... and I'm rather sure it will .. it can lead to stranger things like swinging platforms. Bobbing is fiddling with Z axis. If you fiddle with different 2 axises you get swinging. In an engine with avelocity, you could do more ... ]

One reason why this issue "bothers" me is that it is silly to me a game with Mario in it can do this but that "Quake can't". But my theoretical solution is vanilla Quake engine compatible.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

Ok ... brush submodels models all have origin 0 0 0 and it appears to use mins and maxs to position it.

I guess the traditional entity rules don't all apply here.

I have this 80% working, but I have been having difficulty ensuring that the brush submodels are properly positioned.

In otherwords, if they have an effective center at x,y,z then they should bob a little above the plane and a little below their plane of origin.

And this is yet another reason why "In theory, theory and practice are the same. In practice, they aren't."
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply