On several occasions during the game Gordon gets to use, or gets shot at by, turret-mounted weapons. In WorldCraft, these are all referred to as tanks, and there are four types:
In this tutorial I will be dealing with the func_tankrocket
, but all the 'tank...' entities are similar so you should be able to apply this tutorial to the other types quite easily.
First you should create a basic structure. The only thing you really need is some kind of barrel, but I made mine into a double-barrelled launcher with a tripod base. Anything can be used to make up the barrel, but the one requirement is that it has an origin brush somewhere - usually in the middle. An origin brush is simply a brush (use a cube) with the 'origin' texture on all its faces. Once created, simply select it along with the rest of the barrel, right-click, and select Tie to Entity
Setting up the Tank
from the entity list and give it the following settings:
- Name: rocket
- Yaw range: 90
- Barrel length: distance from origin to end of barrel (42 on example map)
- Barrel horizontal: 0 (if the origin is in the centre, as it should be in this case)
- Barrel vertical: 8 (if origin is vertically centered, it should be 0)
- Smoke sprite: sprites/steam1.spr
- Flash sprite: sprites/muzzleflash2.spr
- Sprite scale: 1.5
- Rate of fire: 0.5
- Damage per bullet: 40
- Bullet accuracy: small cone
Most of those properties can be customised to how you want them. On the flags page, set Controllable
on. The tank entities can be used to create non-controllable weapons - i.e. weapons that shoot at the player. For this you should set Controllable
off and Active
You can also change the pitch settings to make the weapon move up and down as well. The most confusing thing about these things is the way they are aligned. The side of the barrel that you intend the rockets to emerge from means nothing to the game engine, so you need to make the rocket-launching side of the barrel face 0° in WorldCraft, and use the little Angle compass in the Properties sheet to set the direction you want it to appear in the game. For example, my barrel has to face 0° in WorldCraft, because that's where the engine is going to make the rockets shoot from. But I want it to be facing the other way in the game, so I set the compass on the Properties sheet to 180°
. That sorts it out.
When the game starts the tank will face the direction you set, and the axis it rotates on will be the middle of the origin brush.
There's one last thing to do - create a control for the tank. This can be any brush, but it should be large enough to allow the player to move around a little and still have control. You can either make the brush right on the end of the barrel, so that it is as if the player is holding the gun, or you can put it in front of a control panel or something, so that it appears to be remote controlled. The game engine takes the position of the player at the point he presses Use, and alters the position of the barrel according to movements the player makes while he is still in control (i.e within the brush, which is invisible). Make the brush you created a func_tankcontrols
entity, and set its target
(or whatever you called the tank). Because in the game the entity is invisible, it can have any texture, but it's usually given the 'AAATrigger' one.
Thats it! Your tank should now be ready to kill things. Something you might want to try is to target an ambient_generic
sound effect from the func_tankrocket
to create a 'launching' sound.