I thought this might be a good place to ask this question, since there seems to be very little documention on the web about it, and the ChaosUT team is the only one I know working on melee weapons.
Are you guys aware of any melee weapon example code or somesuch? I'm (trying) to play with getting a few working, but the UT2k3 code for things like hit detection and such doesn't work with UT2k4, unfortuantly.
Links or example code or anything along those lines would be greatly appreciated.
Melee Weapons Question
Kuros,
there is no documentation that I could find for melee weapons on UT2k3. We had to do all of our work more or less from the ground up. We did take a quick peak at old Rune Code. But that game was designed around UT/Unreal so most of it did not apply. I have been wanting to write a wiki page on how we did ours and give a working example. Just never have gotten around to it. I promise to do that soobn. If you have any questions feel free to ask.
there is no documentation that I could find for melee weapons on UT2k3. We had to do all of our work more or less from the ground up. We did take a quick peak at old Rune Code. But that game was designed around UT/Unreal so most of it did not apply. I have been wanting to write a wiki page on how we did ours and give a working example. Just never have gotten around to it. I promise to do that soobn. If you have any questions feel free to ask.
Jb
Ok, cool. I'll post my current attempt. I took the original code from a post on 3D Buzz, but it was for UT2k3. I got it to compile under UT2k4, but its not working how I want, atm. here is a copy of the post:
Now, when I shoot the weapon, I get this in the log:
ScriptLog: Found contact! -K
ScriptLog: Name of:
Warning: PuncherFire DM-1on1-Albatross.puncher.PuncherFire0 (Function puncher.PuncherFire.MeleeTargetting:017A) Accessed None 'Other'
ScriptLog: None
It is apparently not finding collision with any actor. I can be right on top of the bot, pointing straight at him, and I still get no name, or anything. I can't find any errors in the hit detection or TraceActors.
Any help is greatly appreciated.
Code: Select all
Melee Hit Detection - Not detecting =/
I took the code from the "Hand 2 Hand" post a pages back, and got it to compile under UT2k4. Here is the code:
code:
function MeleeTargetting()
{
local vector HitLoc, HitNorm, End, X, Y, Z, Start;
local Actor Other;
local rotator Aim;
// Get vectors for where the player is aiming on each axis
GetAxes(Pawn(Owner).GetViewRotation(), X, Y, Z);
// Calculate starting location
Start = Owner.Location + Pawn(Owner).CalcDrawOffset(Weapon) +
Pawn(Owner).Weapon.EffectOffset.X * X + Pawn(Owner).Weapon.EffectOffset.Y * Y
+ Pawn(Owner).Weapon.EffectOffset.Z * Z;
Aim = AdjustAim(Start, AimError);
// Using an arbitrary range of 100 UUs
End = Owner.Location + (5000 * vector(Aim));
// Using TraceActors and a 10x10x10 cube for the extents
foreach Owner.TraceActors(class'Actor', Other, HitLoc, HitNorm, End, Start,
vect(10000.0, 10000.0, 10000.0)) {
}
Log("Found contact! -K");
Log("Name of: ");
Log(Pawn(Other).Name);
}
ScriptLog: Found contact! -K
ScriptLog: Name of:
Warning: PuncherFire DM-1on1-Albatross.puncher.PuncherFire0 (Function puncher.PuncherFire.MeleeTargetting:017A) Accessed None 'Other'
ScriptLog: None
It is apparently not finding collision with any actor. I can be right on top of the bot, pointing straight at him, and I still get no name, or anything. I can't find any errors in the hit detection or TraceActors.
Any help is greatly appreciated.
Try this:
It may not be as accurate but it should work just fine. I think the problem was how the traceactors was set up.....
Code: Select all
function MeleeTargetting()
{
local vector HitLoc, HitNorm, End, X, Y, Z, Start;
local Actor Other;
local rotator Aim;
// Get vectors for where the player is aiming on each axis
GetAxes(Instigator.GetViewRotation(), X, Y, Z);
// Calculate starting location
Start = Instigator.Location + Instigator.EyePosition() + X*Instigator.CollisionRadius;
Aim = AdjustAim(Start, AimError);
// Using an arbitrary range of 100 UUs
X = Vector(Aim);
EndTrace = StartTrace + 1000 * X;
// See if we hit any thing
Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
If (Other != None)
{
Log("Found contact! -K");
Log("Name of: ");
Log(Pawn(Other).Name);
}
}
Jb