Page 1 of 1
Another Melee Question
Posted: Wed Apr 28, 2004 2:15 pm
by Kuros
I have another melee question for ya, JB. =)
Weapons I'm fairly sure I can do now, but I also want to have punches and kicks. But not as weapons. I.e., pressing "Q" in game throws a punch, etc.
I will, of course, need an animation for punching and kicking. However, I am not too sure how to go about tracing a line when there is no weapon. Or even what I would subclass for punches/kicks, since its not really a weapon, more of an inherent ability, like jump...
Anyway, my main question is the tracing thing. I would want to start a trace at the hand or foot, and use the line it follows during the animation to check for a hit. I was thinking maybe I could use the hand IK joint somehow...or maybe not creating an animation, and moving the hand IK joint manually.
Also, is there a way to extract the existing UT2k4 models, so I can just add animations to them, rather than having to make me own (since I'm a very sucky modeller)?
Thanks again
Posted: Wed Apr 28, 2004 3:58 pm
by LoQtUS
Also, is there a way to extract the existing UT2k4 models, so I can just add animations to them, rather than having to make me own (since I'm a very sucky modeller)?
No, there is no way of extracting models. there is on the web however a copy of the 2k3 models in max format that you can use to animate. You can add animations to the 2k4 files but you will destroy any compatability with people that dont have you stuff installed.
Posted: Wed Apr 28, 2004 5:04 pm
by jb
Loq had the 2nd part so let me take the first:
I will, of course, need an animation for punching and kicking. However, I am not too sure how to go about tracing a line when there is no weapon. Or even what I would subclass for punches/kicks, since its not really a weapon, more of an inherent ability, like jump...
Anyway, my main question is the tracing thing. I would want to start a trace at the hand or foot, and use the line it follows during the animation to check for a hit. I was thinking maybe I could use the hand IK joint somehow...or maybe not creating an animation, and moving the hand IK joint manually.
Couple ways to do this. One way is that you know at all time the plays bones, so you can look at say their right hand bone or left hand bone and then do a trace from that out X units to see if that hits any thing. You will have to make sure to get the proper rotation but should be straightfoward to do. Another way could be attach some object to the players hands, make it inv (no mesh, or skin) and then use that ProcessTouch to check for hits. This was is a bit easier as you dont have to worry much about rotation and if your tracing X units out correctly. However since it will be "touching" the player, it will call its processtouch function every tick. So you will want to ensure that it ingores its own player. I think this method would be better as it should have less overhead. Also even though I said tick, dont use tick. Tick is frame rate dependent. So if your getting 66 frames per second, then tick will be called 66 times on your PC. The server is locked to 20 ticks per second. And a faster PC could get well over 100 fps. So keeping everything in sync is not an easy task. Thus use timers.
Posted: Wed Apr 28, 2004 6:05 pm
by Kuros
Can a player have two things in thier hand at once? I.e., a weapon and the invisible object?
Posted: Wed Apr 28, 2004 6:13 pm
by jb
Kuros wrote:Can a player have two things in thier hand at once? I.e., a weapon and the invisible object?
AFAIK yes.
Posted: Wed Apr 28, 2004 6:49 pm
by Kuros
Neat. Now, to figure out how to place an invisible item! -dives into docs-
Posted: Thu Apr 29, 2004 2:18 pm
by Kuros
Okie dokey!
I figured out the whole key press thing (interaction class). Here's the code so far:
Class PuncherInt extends Interaction;
Function Initialize()
{
Log("Puncher Interaction Initialized");
}
function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
{
local vector HitLoc, HitNorm, X, Y, Z, StartTrace, EndTrace;
local Actor Other;
local rotator Aim;
local Pawn C;
local Pawn D;
if ((Action == IST_Press) && (Key == IK_Q)) {
ViewportOwner.Actor.ClientMessage("Q-Key Pressed!");
C = ViewportOwner.Actor.Pawn;
GetAxes(C.GetViewRotation(), X, Y, Z);
StartTrace = C.Location + C.EyePosition() + X*C.CollisionRadius;
Aim = C.AdjustAim(StartTrace, AimError);
X = Vector(Aim);
EndTrace = StartTrace + 100 * X;
Other = Trace(HitLoc, HitNorm, EndTrace, StartTrace, true);
if (Other != None)
{
C = Pawn(Other);
Log("Found contact! -K");
C.TakeDamage(1000, C, C.Location, vect(0,0,1), class'Crushed');
}
return false;
}
}
DefaultProperties
{
bActive = true;
}
Now, the key detection works fine and dandy. If I press "Q" in game, I get a HUD message that says "Q-Key pressed!". Yay!
The problem is with the hit detection and such. On this line:
Aim = C.AdjustAim(StartTrace, C.AimError);
I get this error:
Type mismatch in parameter one.
But this works fine in the MeleeTargetting function that I did previously for my puncher weapon.
For the life of me, I don't quite understand why StartTrace works fine in one function, but not in this one, unless this line:
StartTrace = C.Location + C.EyePosition() + X*C.CollisionRadius;
Is somehow not getting the proper values.
Any ideas?
Posted: Thu Apr 29, 2004 2:28 pm
by jb
AdjustAim has changed in UT2k4:
function rotator AdjustAim(FireProperties FiredAmmunition, vector projStart, int aimerror)
If your using UT2k3 then I would have to look at it some more.
Posted: Thu Apr 29, 2004 2:33 pm
by Kuros
Nope, using UT2k4...but I see the problem now...
Although it puzzles me why this worked:
Aim = AdjustAim(StartTrace, AimError);
In my actual Puncher Weapon, but not in this one. /scratches head
Oh well, I'll stick in the proper values! Thanks again.
Posted: Thu Apr 29, 2004 2:48 pm
by jb
Doh, sorry I was not too clear.
For controllers the adjust aim is different in UT2k4. And thats why it did not work. I posted the controller adjustaim function
For WeaponFire ajust aim is:
function Rotator AdjustAim(Vector Start, float InAimError)
So two different ones

Posted: Thu Apr 29, 2004 3:03 pm
by Kuros
Ah, ok!
So, really, I don't need AdjustAim at all, since its not a weapon, and I won't be tracing using the crosshair, etc. I think.
Aim = C.AdjustAim(1, StartTrace, C.AimError);
X = Vector(Aim);
EndTrace = StartTrace + 100 * X;
Other = Trace(HitLoc, HitNorm, EndTrace, StartTrace, true);
I can use the hand IK bone coords as X, I think, and do away with this whole silly AdjustAim stuff. Does that sound workable?
Note: I'm going with the first option (using bone coords) instead of an invisible object for now, since I can't find anything on how to create one. I'll play with that later, after I get this stuff ironed out.