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
Another Melee Question
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.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)?
The Dark Side of Chaos.
Loq had the 2nd part so let me take the first:
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.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.
Jb
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?
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?
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.
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.