Announcement

Collapse
No announcement yet.

Creating Effective Melee Weapons

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Creating Effective Melee Weapons

    I'm looking for some help on creating an effective melee weapon that works like one ingame. I've found many tutorials on swords in first person that use a little trick where damage is inflicted if touching an object or near it. However, I'm looking for help or a tutorial on the sword's bone(s) doing damage if hit, not by range or touching.

    Here is a video of the system I want to recreate...
    https://www.youtube.com/watch?v=Egad_InYl6I

    I think that a bone maybe attached to the player model/skeletal mesh, instead of the sword/weapon, but I am not sure.

    Thank you for any help or tutorials you give me!

    #2
    I have recently used this tut to create my chainsaw.

    https://www.youtube.com/watch?v=bZWTpPHb0Iw

    it runs a trace along the blade to inflict damage.heres a vid of the first attempt in action.

    Comment


      #3
      So that tutorial is not making the weapon inflict damage on distance/radius? I'll give it try
      Thanks for the help Gaz!

      Comment


        #4
        run a trace.
        Example:

        Code:
        /**
        * Created using Unreal Script Wizard by RyanJon2040
        * Visit: www.dynamiceffects.net
        * Meet me on Facebook: www.facebook.com/satheeshpv
        */
        
        
        class Stick_Weapon extends UTWeapon;
        
        
        var array<Actor> HitArray;
        
        
        var name StartSocket, EndSocket;
        
        
        simulated state WeaponFiring{
            simulated event BeginState( name PreviousStateName ){
                if ( !HasAmmo(CurrentFireMode) ) {
                    WeaponEmpty();
                    return;   
                }
                
                `LogInv("PreviousStateName:" @ PreviousStateName);
                
                PlayFireEffects(CurrentFireMode);
                SetTimer(GetFireInterval(CurrentFireMode), false, 'RefireCheckTimer');
            }    
            
            simulated simulated event EndState( name NextStateName )
            {
                HitArray.Length = 0;
                `LogInv("NextStateName:" @ NextStateName);
                ClearTimer('RefireCheckTimer');
                NotifyWeaponFinishedFiring( CurrentFireMode );
                return;
            }
            
            simulated function RefireCheckTimer()
            {
                if (bWeaponPutDown){
                    `LogInv("Weapon put down requested during fire, put it down now");
                    PutDownWeapon();
                    return;   
                }
                
                if ( ShouldRefire() ){
                    HitArray.Length = 0;
                    PlayFireEffects(CurrentFireMode);
                    SetTimer(GetFireInterval(CurrentFireMode), false, 'RefireCheckTimer');  
                }
                
                HandleFinishedFiring();
                return;
            }
            
            function Tick( FLOAT DeltaSeconds ){
                local vector Start, End;
                
                SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndRotation(StartSocket, Start);
                SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndRotation(EndSocket, End);
                
                WeaponTrace(End, Start);
            }
            
            simulated event WeaponTrace(vector End, vector Start)
            {
                local vector HitLocation, HitNormal;
                local Actor HitActor;
                
                HitActor = Trace(HitLocation, HitNormal, End, Start, true);
                
                if (HitActor != none){
                    if (HitArray.Find(HitActor) == INDEX_NONE && HitActor.bCanBeDamaged){
                        HitActor.TakeDamage(InstantHitDamage[CurrentFireMode], Pawn(Owner).Controller, HitLocation, Velocity * 100.f, class'Stick_Damage');
                        AmmoCount -= ShotCost[CurrentFireMode];
                        HitArray.AddItem(HitActor);
                    }   
                }
            }
            
            begin:
            FinishAnim(AnimNodeSequence(SkeletalMeshComponent(Mesh).FindAnimNode(WeaponFireAnim[CurrentFireMode])));
        }
        
        
        
        
        DefaultProperties
        {
            ShotCost(0)=0
            ShotCost(1)=0
            
            WeaponFireTypes(0)=EWFT_Custom
            WeaponFireTypes(1)=EWFT_Custom
            
            StartSocket = StartSocket
            EndSocket = EndSocket
        
        
            PlayerViewOffset=(X=20.000000,Y=0.00000,Z=-8.000000)
        
        
            Begin Object class=AnimNodeSequence Name=MeshSequenceA
                bCauseActorAnimEnd=true
            End Object
        
        
            Begin Object Name=FirstPersonMesh
                SkeletalMesh=SkeletalMesh'tutorial.SkeletalMesh.SK_Stick'
                FOV=60
                Animations=MeshSequenceA
                AnimSets(0)=AnimSet'tutorial.SkeletalMesh.Cylinder'
                bForceUpdateAttachmentsInTick=True
                Scale=0.9000000
            End Object
        
        
            Begin Object Name=PickupMesh
                SkeletalMesh=SkeletalMesh'tutorial.SkeletalMesh.SK_Stick'
                Scale=0.9000000
            End Object
        
        
            WeaponEquipSnd=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_RaiseCue'
            WeaponPutDownSnd=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_LowerCue'
            WeaponFireSnd(0)=SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_GrenadeFire_Cue'
            WeaponFireSnd(1)=SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_GrenadeFire_Cue'
        
        
            PickupSound=SoundCue'A_Pickups.Weapons.Cue.A_Pickup_Weapons_Shock_Cue'
        
        
            PivotTranslation=(Y=0.0)
        
        
            MaxAmmoCount=0
            AmmoCount=0
        
        
            InventoryGroup=4
        
        
            bInstantHit=True
            InstantHitDamage(0)=50
            InstantHitDamage(1)=20
            InstantHitMomentum(0)=300
            InstantHitMomentum(1)=500
            InstantHitDamageTypes(0)=Class'Stick_Damage'
            InstantHitDamageTypes(1)=Class'Stick_Damage'
        
        
            //CrosshairImage=Copy texture from Content Browser
            CrossHairCoordinates=(U=384,V=0,UL=64,VL=64)
        
        
            FireInterval(0)=1
            FireInterval(1)=1
        
        
            //<DO NOT MODIFY>
            ArmsAnimSet=AnimSet'tutorial.SkeletalMesh.Cylinder'
            Mesh=FirstPersonMesh
            DroppedPickupMesh=PickupMesh
            PickupFactoryMesh=PickupMesh
            AttachmentClass=Class'Stick_Attach'
        
        
        }
        - There should be many tutorials on this thing, quicker for me to post code than to search for you
        - Oh and i think RyanJon (author of ↑↑↑) is still an active member, so if you get stuck, so just follow the links in the code

        Comment


          #5
          Before creating a trace function take in consideration, that you can create a lot of variations out of it, depending on wich kind of melee weapon you want to use it with, and the functionality that you want it to provide aswell.

          - For instance, let's say that you want your trace function, to return you the speed, *v of your weapon after it hit something. You will need a variable that will show you the time between trace and trace, and the length, and v = Length/Time.

          - Or for instance you want your trace to be as realistic as possible, then the traces shall be multiple and faceing the same direction as the weapon is striking at, to also provide realistic normals.

          - Or for instance you want your trace to, trace the mesh, in case you want the most realistic, collision " wich is traceComponent" but ofc you first need the variable of the component you want to use.

          These are just things that you shall take in consideration before making a trace function, You can A, straight copy paste, and have something that is capable of more, or B use your brain, and add to your tracing functionality something more complex but that in the end it will give to your gameplay more variety and it will make it richer and more rational.

          If you feel like you want/need any of these 3 functionalities that i posted, tell me that i will explain them more in depth on how to create em : P .

          Comment

          Working...
          X