Alright, so here's another tutorial that directly follows along with my current map project :).
This time, we're going to force a bot that we spawn in the world to move to a location of our choosing. For my example, I'll use the other team's flag.
To start out, right click a place in the world and add a trigger. This is going to dump out the Pawn data into Kismet so that we can control him. With that Trigger selected, open up Kismet and right click the empty space to bring up the menu. Add a new event using trigger... > Touch.
Now that you've got the trigger setup, be sure to make a blank object variable below the trigger so that the value of the pawn is dumped somewhere. Create a new action now, New Action > AI > Move to Actor (latent). Now hook these up in the traditional left to right from Touch to In. Now pull the target input into the object variable you created. With that done, now all you need is another object for your movement target. Find something on your map that you want you pawn to go run over to and select it. Bring Kismet back up and right click on the blank input. Create Object using whatever is selected, for me it's RedTeamFlagBase_0.
Now, whenever the bot hit's our trigger, he will immediately stop what he's doing and move to the target location...
This is all well and good, but if you're going along with my example, what do you think is going to happen when the Pawn comes back over that trigger carrying the flag? What about opposing team members? With the way it's setup, any bot who hits the trigger is going to turn around and run for the flag point, so let's add in some more safety precautions.
In order to make sure that your trigger isn't going to be turning the other team away from your base, add a new action into your function. New Action > Team > Get Team Number. Connect the object variable from the trigger into the target input of this node. This will tell the process who it's checking. Next, create a new Int variable underneath the output of the Get Team Number. Now add a new item. New Condition > Comparison > Int. Connect the Int value from the team node into the A slot of the Int compare. Create another Int at B and assign it to either 0 or 1. 0, being red team and 1, being blue team. Depending on what you choose, set this up accordingly. I used 0, so I check to see if my Get Team is = 0, then I connect that output to my Move to Actor function. What this is doing is checking if the pawn who triggered the touch is going to be on Red team. If they are, then they'll be sent over to the flag. If not, then I don't have to worry about making them do anything.
Now, this may or may not be important as I haven't gone to figure out if the bots will run to the Flag or to the Flag Base... but you may want to add in another condition in there that checks whether or not the bot is carrying the flag. This would stop a bot who had the flag from triggering our event and running back to the other base to be killed. So just to be safe, I'll go ahead and add that part in.
That's about it for today. Again, if there's anything you'd like to learn in particular, just ask and I'll be happy to go over it.
Thursday, April 28, 2011
Wednesday, April 27, 2011
Creating a spawned Turret in Unreal Editor 3
If you were to make a game where you needed a turret to be spawned and attack an enemy in real time, the best way to achieve it would be using Kismet.
Before opening up Kismet at all, first decide on the area in your map where the turret is going to be placed. Right-click on the spot and add a PlayerStart actor. Add another actor close-by but not too close. (This second player start will be for the turret's bot so that there will be someone to shoot from it.) If the two points are too close together, that the bot will die on spawning due to the turret being too close to spawn point. (Ever seen a two players spawn in the same location? Needless to say, one of them usually explodes.)
Now, with your spawn points in the world, open up Kismet.
Depending on what you're using it for, you'll need a different trigger to set off our event. So for the sake of testing, I'm going to set it up on a console event. (Add Event > Misc Event > Console Event). Be sure to add a name into the ConsoleEventName space so that you can call it from game. Mine is going to be "testturret". When you activate this in-game, you'll press tab to open console and type "ce testturret".
Next, add two Actor Factories (New Action > Actor > Actor Factory). Connect the out from the event into the Spawn Actor of the actor factory. Next, connect the Finished of the first to the Spawn Actor of the second.
Now we're going to make our Object variables. With the player spawn of the turret selected, right click on the first actor factory's Spawn Point and click create object using PlayerStart_x. Do the same for the other spawn on the other actor factory. After that, right click on the Spawned part and create a blank object variable for each factory.
With the first one selected, click the blue arrow to the right of Factory. From the drop-down, select the UTActorFactoryVehicle. Then, from the VehicleClass drop-down, select UTVehicle_Turret. This is pretty much all you need to spawn the turret in the world. Go ahead and change the TeamNum value to 0 for Red or 1 for Blue if you're using it in a team game.
Now Select the second factory and do something similar. This time, select UTFactoryAI. After that, go down into the PawnClass and change him to a UTPawn. Again, change TeamIndex to either team if need be, 255 defaults to a Deathmatch bot. Go ahead and give him a PawnName if you'd like.
Our next step is to force that pawn to get into the turret we created. Create a New Action > Pawn > Enter Vehicle. Connect the finished from the second Actor Factory to the In of the Enter Vehicle. Now connect the Target to the (???) object of the second Actor Factory and the Vehicle to the (???) from the first Actor Factory. This will effectively force that bot that we created into being the targeting system for our turret. We could stop here, as this will create the turret and man it, but there's nothing keeping that bot from leaving the turret if he gets bored or finds something important to do. In order to keep him in there, we'll add a delay loop right on top of the enter vehicle. Create the new Delay from New Action > Misc > Delay. Connect the Out of the Enter Vehicle to the Start of the Delay. Now connect the Finished of the Delay to the In of the Enter Vehicle. With this in place, the pawn will be forced to get back into the turret every second, effectively making him a permanent targeting system. (or at least until someone kills him or the turret.)
This concludes the turret tutorial! Get in the game and type "ce testturret" in the console to see them spawn!
If you have any questions or comments, feel free to leave them below. If you have a specific topic you'd like me to go over, feel free to ask!
-Ken
Before opening up Kismet at all, first decide on the area in your map where the turret is going to be placed. Right-click on the spot and add a PlayerStart actor. Add another actor close-by but not too close. (This second player start will be for the turret's bot so that there will be someone to shoot from it.) If the two points are too close together, that the bot will die on spawning due to the turret being too close to spawn point. (Ever seen a two players spawn in the same location? Needless to say, one of them usually explodes.)
Now, with your spawn points in the world, open up Kismet.
Depending on what you're using it for, you'll need a different trigger to set off our event. So for the sake of testing, I'm going to set it up on a console event. (Add Event > Misc Event > Console Event). Be sure to add a name into the ConsoleEventName space so that you can call it from game. Mine is going to be "testturret". When you activate this in-game, you'll press tab to open console and type "ce testturret".
Next, add two Actor Factories (New Action > Actor > Actor Factory). Connect the out from the event into the Spawn Actor of the actor factory. Next, connect the Finished of the first to the Spawn Actor of the second.
Now we're going to make our Object variables. With the player spawn of the turret selected, right click on the first actor factory's Spawn Point and click create object using PlayerStart_x. Do the same for the other spawn on the other actor factory. After that, right click on the Spawned part and create a blank object variable for each factory.
With the first one selected, click the blue arrow to the right of Factory. From the drop-down, select the UTActorFactoryVehicle. Then, from the VehicleClass drop-down, select UTVehicle_Turret. This is pretty much all you need to spawn the turret in the world. Go ahead and change the TeamNum value to 0 for Red or 1 for Blue if you're using it in a team game.
Now Select the second factory and do something similar. This time, select UTFactoryAI. After that, go down into the PawnClass and change him to a UTPawn. Again, change TeamIndex to either team if need be, 255 defaults to a Deathmatch bot. Go ahead and give him a PawnName if you'd like.
Our next step is to force that pawn to get into the turret we created. Create a New Action > Pawn > Enter Vehicle. Connect the finished from the second Actor Factory to the In of the Enter Vehicle. Now connect the Target to the (???) object of the second Actor Factory and the Vehicle to the (???) from the first Actor Factory. This will effectively force that bot that we created into being the targeting system for our turret. We could stop here, as this will create the turret and man it, but there's nothing keeping that bot from leaving the turret if he gets bored or finds something important to do. In order to keep him in there, we'll add a delay loop right on top of the enter vehicle. Create the new Delay from New Action > Misc > Delay. Connect the Out of the Enter Vehicle to the Start of the Delay. Now connect the Finished of the Delay to the In of the Enter Vehicle. With this in place, the pawn will be forced to get back into the turret every second, effectively making him a permanent targeting system. (or at least until someone kills him or the turret.)
This concludes the turret tutorial! Get in the game and type "ce testturret" in the console to see them spawn!
If you have any questions or comments, feel free to leave them below. If you have a specific topic you'd like me to go over, feel free to ask!
-Ken
Subscribe to:
Posts (Atom)



