Tip:
Highlight text to annotate it
X
OK, go File, Open. We're gonna load KismetTutorialStart.
Now go over to the content browser and in the Actor Classes tab, uncheck Show Categories.
Expand Pawn and Game Pawn, and I'm gonna drag a MobilePlacementPawn into the world.
If you double click it, it will bring open its properties
and we're gonna go to the movement tab, Location and we'll zero this out with
zero, zero and on the vertical let's do 58.
Close movement, open up Pawn, Mesh, SkeletalMesh.
Now I wanna set three things in here so he can animate correctly.
So go back to the content browser, go to the KismetGameAssets tab,
right click and go Fully Load.
Then go down to the Anims folder and filter by "Jazz"
and that will just show us his stuff.
Select the SK_Jazz skeletal mesh, and we'll assign that to the skeletal mesh.
And then Jazz_AnimTree and we'll assign that to the AnimTreeTemplate.
And then SK_JazzAnims for the AnimSet. Over here in the AnimSets section
we'll hit the green plus to add a slot for it, and hit the green arrow and that assigns that.
Now he's got all the stuff he needs to animate. Close those down.
Let's select him and type in C-O-L to check on his collision.
And if And if you hit C on the keyboard, it'll show up.
You can see the little green cylinder around him is his collision cylinder.
So let's make that a little fatter, we'll set it to 35, looks about right.
Now let's set up the camera.
So go to the Actor Classes, select on Camera Actor
and we want to drag one of those into the world. Double click it.
Go to its Movement, Location. We're gonna zero this out to 0,0,0.
We're also gonna need two cameras.
So if you hold down Alt and drag, you can duplicate that one.
So the first camera, we're gonna link that to the player.
So, open up its properties and go to Attachment,
and click on the little lock up here, and that will keep this property selected,
and then you can click on the character and link it,
and we also want to hit HardAttach and also Ignore Base Rotation
because we don't want this camera to rotate with the player.
We're gonna take this camera and end up linking it to this camera,
but we want to position it first.
So close this stuff down, select this camera.
If you hit the little eye-ball up here, you'll take over this camera,
so you can actually easily go and position it, to how you want to see it in your game.
That looks pretty good.
So unclick the eye-ball and you can move back and you see this camera is now up in the air.
Now if we double-click that camera, we also want to open up its camera properties
and turn off ConstrainAspectRatio, and we wanna set the FOVAngle to like 65,
and then we also wanna go to its attachment tab and hit the lock on it,
and we wanna select the other camera that's linked to the character
and base this one off of it, and click HardAttach.
OK, now that we've got our guy setup to animate, and we have our camera setup,
let's go ahead and give him some player control.
So we're gonna do that in Kismet, our visual scripting language.
So if you hit the K up here, it'll pop that open.
If you right click and go New, Event, Input, here's all the new Mobile stuff that we've added
for accessing all the tilt and touch data coming off your iOS device,
we're gonna use the MobileLook controller which is basically like a thumb-stick controller.
You basically have two thumbsticks by default on-screen.
We're gonna use one for his look direction and the other for his movement direction,
so this will be the right stick and it's called "UberStickLookZone".
We'll add that in. Now that's linked up, so we now need to setup the Yaw.
So if you create a new Float Variable for that. Right click and go New Float Variable.
We're gonna take the Yaw, which is basically the direction the stick's pointing towards
and set it into a vector component. So go New Action, Math, Set Vector Component
and we're gonna drive the Y with the Yaw and we're gonna output that into a vector.
So right click on Output Vector and create a new Vector Variable
and then connect the Input Active to the Input on Set Vector Component
and from that we want to set the Actor Location and Rotation which is
New Action, Actor, Set Actor Location.
And we're gonna set the Rotation for this Actor from this output vector.
So connect that to the Rotation input and then connect the two nodes together,
and select this node and we also wanna turn off Set Location
because we only wanna set Rotation on this guy.
So now that's hooked up, let's give it something to drive.
We're gonna drive our little Pawn guy with it,
so select him and then right click and go New Object var using MobilePlacablePawn0.
And that will assign our Pawn as the thing to be controlled by this thumbstick.
OK, so we should be all good with our rotation.
OK now let's setup the movement controls.
We'll take the look control and hit Control-C, Control-V to paste it.
We can right click, Break All Links, and then select it and
we're gonna change this to MoveZone instead of LookZone. So this uses the left stick.
Now we need to right click on strength and add a New Float Variable.
We're gonna take the Strength, which is basically
how far away from the center of the control the thumb-stick is, and that's gonna drive our speed.
And then also we're gonna take the Direciton and drive the movement direction.
So let's....
now we have our speed here, let's take that and we wanna create a rotation vector as well
so we'll right-click and create a new variable for that. We're gonna take this variable,
the speed variable and multiply it by a variable so it's easy to change the speed.
So let's go New Action, Math, Multiply Float, and then we wanna drive that from the strength,
and then we wanna create a new variable for B to multiply it by, so create a new variable for that.
And then we wanna create a new variable for the float result.
So when it's active, we're gonna drive the initial strength by multiplying it by this variable,
which I set that to like 3 times,
and we're going to dump that variable out into the float result.
We're going to use the float result and use it to set the velocity for this guy,
so let's do New Action, Actor, Set Velocity
and drive that into there, set the target to our little pawn guy,
and then we wanna drive the velocity direction from the rotation vector
and the velocity magnitude from the result of our multiply float.
That should set us up to make him move around by the speed of how far away the stick is from the center.
OK, now that we've got this control setup so when this control is active,
we're moving the player around by the strength, we need to set up what happens when you let off.
So what we wanna do is manually you know kinda slow him down to come to a stop.
The thing with this control is when it's active, it's sending out a constant stream of data,
but when the inactive trigger is fired, it's only going to be a one time thing,
so we need to setup a little condition down here,
a comparison to loop it through and bring it to a stop.
So let's do that by going New Condition, Comparison, Compare Float, and
we want to compare our speed variable here in the A input to a new variable we'll create, of zero.
So we'll say when inactive, go into this comparison and if the number is greater than zero,
then we wanna do something. What we wanna do is subtract,
so go New Action, Math, Subtract Float.
We want to subtract from the speed variable,
we want to subtract 20, we I'll put a new variable of 20,
and we want to dump the result of that back into the speed variable.
OK, so if A is bigger than B, subtract 20 and write it back into the variable.
Then we need to set the velocity again,
so we'll take that Set Velocity up there and hit Control-C, Control-V to create a copy.
You can leave these connections the way they are, we want them to be the same.
The reason we're making two of these is because
we want to loop this one, and we don't want to loop that one.
So go to the Set velocity output and right click
and you can actually go Set Active Delay, we'll set that to 0.01.
So now, after it gets done it'll loop back to the comparison
and if the number is still greater than zero, it'll reduce it by 20
and keep going through until he comes to a stop.
We don't want the number to below zero, so to prevent that we're gonna do a
New Action, Set Variable, Float so if the number is less than or equal to zero,
or actually just less than zero, we want to set it to zero,
so we'll create a new Float Variable of zero, drive that into the Set Velocity,
and we need to set the target to the Speed variable.
So now we've got it all set up to bring you to a stop, smoothly.
OK now that we have these controls setup, let's go ahead and give him his gun.
Just close Kismet, go round here so we can see his right hand,
open up the Content Browser, and drag SK_JazzGun into the world.
If you go up the View here and go Enable Socket Snapping,
and then you can just click on the little socket in his right hand
and it'll put his gun in there and attach it up, and now he's got his gun.
OK now let's make his gun shoot.
So we'll go back into Kismet and we'll go to the shooting area that I added.
We wanna right click, go New Action, Actor, Projectile Factory,
select that and we also wanna open up the Content Browser and go down to Projectile,
get rid of the Jazz filtering. select our Projectile Factory
and we want to add a Archetype to it, under the Factory
and then we want to point the Archetype to the Blaster_01,
so type in Blaster_01, that links that up.
So now when this is fired, it'll launch this projectile here.
We also want to setup a muzzle flash,
so if you scroll up on the Projectile Factory settings,
and the PSTemplate is the particle system to use for the muzzle flash,
so we want to use the BlasterMuzzle_02 so select it and then hit the green arrow,
and it'll assign it.
And the socket name - this is the socket on the gun,
we want to assign for the projectile to be launched from,
so there's a socket called Muzzle, M-U-Z-Z-L-E
on the front of the gun we just added.
So we also need to select our gun, and then add it as the spawn point,
under the Projectile Factory, so now whenever this fires,
it'll launch this projectile from this socket at the barrel here.
Now we need to setup how we're going to trigger this projectile factory.
We wanna use the MobileLook from the right stick. So let's go...
The problem with that is it's a continuous stream of data,
and we need to kinda limit how often it's going to shoot.
So we're gonna do that with New Actions, Switch and add a Switch,
we're gonna select the switch and set the Link Count to 2.
This is basically like a gate so whenever the signal comes in from the right stick,
if this index variable that we create is set to 1, it's going to spawn one projectile.
And then also at that time we're going to go New Action, Set Variable, Integer,
and we're going to set the index to variable of 2.
So that way it basically is dumping it into 2,
so it's not going to go anywhere so it's going to stop it from firing,
and then we're gonna add a New Action, Miscellaneous, Delay,
and we're gonna set our delay to Float Variable there,
we're going to set it to like 0.2,
and then after that we're going to copy this Set Integer over to here,
break that link and so once the delay is done,
it's going to set this index variable back to 1.
So every 0.2 seconds, it'll fire a projectile.
And there we go.
OK let's select all this and straighten it up a bit.
Now all that's left to do is setup our camera,
so let's go New Event, Level Loaded. So when the level's loaded,
we want to go New Actions, Camera, Set Camera Target,
and we wanna select our camera that we have in the world, that's the game camera.
We want to assign that to the Camera Target,
and if you hold down P and click, it'll add a variable for the player.
So basically when the level is loaded and visible,
we want to set that camera as the camera that the player sees through.
Now we're pretty much done, other than the one other thing that we wanted to do -
now that we're using our own custom Pawn, we need to take control away from the other game pawn,
so to do that, we're gonna go New Action, Toggle, Toggle Input.
We're gonna turn off input to the regular player, and so we just set the target of this to
the same player icon, and we should be good to go.
We should have a playable game now. We should be able to move around and shoot.
Before I run this, I want to add a quick blob shadow. So go to your mesh tab, and grab SM_Shadow_01,
right click and add an InterpActor, hit F4, we want to set this to be 7, zero and 13
with a DrawScale of 0.8. And we want to lock the lock,
select our player, base it on him, do a Hard Attach, and uncheck Shadow Parented.
Now he's got a shadow!
Now I wanna go to go ahead and run this on the Mobile Previewer and I'm going to use UDK Remote,
which is a free App on the App Store that lets you use an iPhone as an input device to control it.
These two work great together and allow you to iterate on your game really quickly.
Author: Shane Caudle @ Epic Games
Transcription: Jack Porter Translation & Sync: Sungjin Hong @ Epic Games Korea