I'm using SDK 2007.
Here's what func_tank does in it's Think cycle:
...
SetLocalAngularVelocity(vec3_angle);
...
AimBarrelAtPlayerCrosshair( &angles );
RotateTankToAngles( angles ); // this calls
SetLocalAngularVelocity()
SetNextThink( gpGlobals->curtime + 0.05f );
SetMoveDoneTime( 0.1 );
return;
So in looking at Func_tank, it seems like every think the barrel's rotation is
stopped
and then started again. I can't tell if the SetMoveDoneTime has any effect,
but when
I copied this code to my turret, the barrel bobbed back and forth at a think
time of 0.2
(no wonder this code uses 0.05)...
When I noticed the barrel bobbing back and forth in my copied code, I tried
using SetMoveDone() on
a functio that would print a Warning message, but it never got called.
As for my aim layer questions, here's what I've been using for one of my custom
player models:
$animation a_aimN "mech_aim" frame 4 4
$animation a_aimDL "mech_aim" frame 0 0 subtract a_aimN 0
$animation a_aimDM "mech_aim" frame 1 1 subtract a_aimN 0
$animation a_aimDR "mech_aim" frame 2 2 subtract a_aimN 0
$animation a_aimML "mech_aim" frame 3 3 subtract a_aimN 0
$animation a_aimMM "mech_aim" frame 4 4 subtract a_aimN 0
$animation a_aimMR "mech_aim" frame 5 5 subtract a_aimN 0
$animation a_aimUL "mech_aim" frame 6 6 subtract a_aimN 0
$animation a_aimUM "mech_aim" frame 7 7 subtract a_aimN 0
$animation a_aimUR "mech_aim" frame 8 8 subtract a_aimN 0
//
// these are the original, but left/right/up/down are all reversed...
// but changing the matrix doesn't help :D
//
//a_aimUR a_aimUM a_aimUL
//a_aimMR a_aimMM a_aimML
//a_aimDR a_aimDM a_aimDL
$sequence aim_layer {
a_aimDL a_aimDM a_aimDR
a_aimML a_aimMM a_aimMR
a_aimUL a_aimUM a_aimUR
blendref a_aimN
blendcenter a_aimMM
blendwidth 3 calcblend aim_yaw "attach_RH" ZR calcblend
aim_pitch "attach_RH" YR
delta
}
The mech_aim file contains frames 0-8 of a model that looks down/left,
down/mid, down/right; mid/left, mid/mid, mid/right; up/left, up/mid, up/right;
up/more... (just like the example human code)
I thought I could make a turret model that used a similar technique for some
kind of vertical/pitch control only,
but I've had bad luck changing the blendwidth/calcblend parameters, even the
nature of th attachment bone can
cause model compilation failure... but basically, I think it would be a
blendwidth X calcblend aim_pitch "muzzle" YR.
But then again, I don't understand blendwidth/blendcenter much...
Eric
On Fri, Oct 04, 2013 at 12:38:12PM -0500, Nick wrote:
> which version of the SDK is this?
> can you post the code in question?
>
>
> On Fri, Oct 4, 2013 at 10:48 AM, <[email protected]> wrote:
>
> > Hello,
> >
> > I've been working on a simple auto turret based on code in
> > server/hl2/func_tank.cpp, and I've got a few questions about making
> > something like a turret barrel rotate smoothly when tracking a target:
> >
> > - func_tank uses SetMoveDoneTime() in a few places, but it never sets the
> > callback with SetMoveDone(). I've a little confused by this, because I
> > figured that it would/should use SetMoveDone() to reevaluate whether or not
> > the barrel should stop rotating, but instead it does this on every think
> > interval by calling SetLocalANgularVelocity(vec3_angle). Why does this
> > class bother setting SetMoveDoneTime()?
> >
> > - In my turret code that's based on func_tank, I tried using SetMoveDone()
> > and SetMoveDoneTime(), but the callback never got called... After looking
> > through the sdk a bit, I'm wondering if these functions are only for
> > vphysics/MOVETYPE_PUSH objects? Why?
> >
> > - In any event, right now when I want to aim the turret barrel at a target
> > now, I just call SetLocalAngles() instead of SetLocalAngularVelocity(). I
> > suppose this would produce choppy rotation in a network with more latency,
> > and ideally, I'd like to have smooth rotation. What's the best way to do
> > something like that? It seems like if I use SetLocalAngularVelocity() the
> > rotation might be smooth, but if the Think interval isn't fast enough, the
> > turret barrel willl never be able to stop when it reaches the ideal/target
> > angle. Is there a good way to tell an object to smoothly rotate until it
> > reaches an target angle?
> >
> > - Right now my turret has a fixe base and a head model that gets rotated
> > with SetLocalAngles(), but I'd like to use a model that takes yaw/pitch
> > parameters to achieve this animation. Are there any good examples of
> > models and QC files that can pitch 360 degrees and have a more limited yaw
> > range? Should I just make a model that takes a yaw pose parameter for
> > vertical aiming, and then use something like SetLocalAngles() to control
> > the pitch? What would this look like in QC (an animation/sequence that
> > only takes a yaw parameter)?
> >
> >
> > Sorry for all of the questions, but on a separate note:
> > - I've made several player models and did the aim layer animation similar
> > to the SDK examples for humans (hl2mp), but I have one problem: The aim
> > direction appears to be inverted! (using thirdperson to view) I tried
> > inverting the parameters in the QC file, but it doesn't appear to have any
> > effect. I think I've reached the point where I need to really understand
> > how the animation blending subsystem works so that I can sort out these aim
> > layer problems, and maybe make a turret model as well. There's no
> > documentation about "calcblend", and despite tons of googling, I still
> > don't fully understand the blend/blendwidth options for generating
> > sequences (the order of the aim directions, how the input parameter affects
> > which two keyframes are being interpolated...). Does anyone have some
> > definitive examples of how blending works, or is there some really detailed
> > documentation of these features somewhere? Any help on this subject would
> > be very helpful.
> >
> > Thanks,
> > Eric
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
> >
> >
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please
> visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders