Me Lee Weapons

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Melee Weapons Without Programming

In this tutorial, you will be learning how to make melee weapons work inside the UDK/UT3 engine with only Kismet. While this is not the best way to do this, it is a great way to get an idea off the ground and to a prototype stage. You are expected to understand how to build a level in UT3/UDK and know how to navigate around the menus as well for this tutorial. We will be animating a sword as well, so you are expected to know how to animate objects in matinee as well. For this tutorial, you will need: 1 1024 x 1024 x 1024 subtractive cube level 1 Player Start 1 Pathnode 1 Sword like weapon (if you do not have one it will be okwe will show you where one is) 1 Kill Volume 1 Light to light the level 1 Dynamic Trigger Volume 1 - Trigger And a lot of Kismet. Here is what my level looks like:

I have the player start on one side of the level and the path node on the other. The path node is where we will be spawning the enemy that will want to kill. Next we need our sword:

You will see from above that you can import your sword static mesh or just find a long skinny object in the Generic/Content Browser. In this case, Im using UDK and just turned on the Static Mesh options to find S_Double_Twist. For a lack of a better reasonthis will be an energy sword of some sort. Be sure to select it and then inside your level, right click on the floor and add it as an Interp Actor, so we can animate it.

The next step is a little time consuming, but you have to place the sword in the correct spot, so that when you are spawned, the sword is in the correct spot. Here is where, I placed mine, but yours might be different.

Here is a shot in game:

Now, we need to get rid of the gun: Inside the VIEW Menu, select WORLD PROPERTIES. Then check NO DEFAULT INVENTORY FOR PLAYER under WORLD INFO.

You should see this when you play the game:

Now for some Kismet. In order to make this a weapon, we have to animate it to swing. In Kismet, we need this (a Mover):

Notice that my sword was selected when I went to kismet. Then I right clicked and added a MOVER script as my event with this InterpActor, which looks like this:

Be sure to delete the InterpActor Mover from the left. We do not need it. We just need the Matinee on the right. Now, double click in the matinee and animate the sword to swing the way you want it. Here is what I came up with:

So, now that we have the sword animated, we have to get it to work inside the game. First we will attach the sword to the player and then have it animate on a button press. Here is the kismet:

Youll see that When the level starts (New Event > Level Startup) that we are attaching the sword to the player. To use the attach, go to New Action > Actor > Attach to Actor. For the player, depending on the version of UT3/UDK you are using, it will be under New Variable > Object > Player or New Variable > Player > Player. Drag the pink box under Target to the player variable. Now select the sword in your level and then right click on the pink box under the Attachment and pick the sword from the drop down list. Some things to noteIf we did not set up the sword location in the beginning, we could with the Attach to Actor. If you look in the image above, in the properties you will see a Relative Offset and Relative Location. If you turn them on and adjust the numbers, you will see that you can control how something attaches to the player, etc.

Below you will see the properties of the player variable:

You dont have to, but you could uncheck ALL PLAYERS and keep the player index at 0 for the main player. Ok, so if you test it, your sword should follow you now. Now we need to add a button press. For a button press to work, the easiest way is with a triggerwe need to add a trigger to the player start area.

You will see that my trigger is over lapping the player start so when the player spawns, the trigger can attach to him as well and follow him around so when we press the E key, the sword will swing.

With your trigger selected, go back into Kismet and do another Attach To Actor for the Trigger and Player.

Youll notice I added a Delay of one second before I attached the swordthis just helped clear up an issue I was having in my level. Doing this tends to help fix a lot of issues I find. To do it, just right click on any black OUT box and set the Activate Delay Option. If you want to get rid of it, just set it to zero. So, I have attached my trigger to my player when the level starts. You might be asking, why do we need two attach to actors??? Well, Ive found that in UDK attaching multiple items on one attach to actor does not work, but feel free to try it on your system. So, test it and be sure the trigger is following you around. To do that, click on your trigger and in the DISPLAY section, be sure to uncheck HIDDEN so you can see it in game.

Ok, now that it works, we need the kismet:

If you select the trigger and right click in Kismet, you can create a USED TRIGGER EVENT. Be sure to add that to the PLAY INPUT of the MATINEE so when we press the E key, we can play the animation of the sword swinging. Also, be sure on the trigger properties to uncheck AIM TO INTERACT so we do not have

to look at the trigger to get it to work, and put the MAX TRIGGER COUNT to ZERO so we swing the sword a lot. Check it and see if it worked. Some things to note, If it did not work, double click on the matinee in Kismet and then right click on your movement track of the sword. You might have to set it to RELITIVE TO INITIAL so it will animate wherever it is instead of in the same spot everytime.

Something elseIn Kismet, I clicked on the Matinee and in the properties I changed the PLAYRATE to 3 to make the sword swing faster. You can re-animate it if you like, but Id rather just type in a number. Also, I checked REWIND ON PLAY so it always goes back to the first keyframe after playing the entire animation.

Try it again and see if it worked. You should have a sword that follows you around the level and swings at enemies. This works for many items like torches, guns, inventory items, etc. Now we need an enemy. Hopefully, you know how to spawn a character, but if not, here is the kismet:

We will have an Actor Factory Spawn a guy when the level starts. We will spawn him on the path node we created earlier.

You can see that I have added the path node in and under the spawned 1, I have just added a blank object variable...it seems to work better when you do that. Now, inside the Actor Factory Ex properties,

there is a BLUE DOWN ARROW. Hit that and select UTActorFactoryAI. This will give us the enemy. All you have to do is switch the PAWN CLASS to UTPAWN for a character to spawn.

Ok, so we have a sword that swings and a player to kill. There is just a few more steps. You will notice in the image below, I have made my builder brush a lot smallerx=15, y=15, z=25, and I placed it at the tip of the sword. We are going to attach a trigger volume to the end of the sword to record damage.

There are a few ways to do this, but we are going to use a DYNAMIC TRIGGER VOLUME.

So, once your brush is in place, right click on the blue cube that creates volumes and pick the DynamicTriggerVolume. We are using this because the DYNAMIC ones can be attached to the player and animated/moved.

As you would expect, there is some Kismet. Here it is. I attached the volume to the sword.

Then I created a TOUCH TRIGGER EVENT.

You can see that when the trigger is touched by the guy I just created with the Actor Factory Ex, I am going to modify his heath by 100%...aka kill him. You can find the modify health under New Action > Actor > Modify Healthand you do not have to kill himyou can just damage him if you like. Give it a try.

So, again, here is the total kismet.

You might also like