Now, we are going to add the UFO as an actor to our existing game, with a predefined behavior:
2. Open
InvadersGame.cs
.3. Add the following
private
variable in thepublic class InvadersGame : RealTimeGame
, to hold the newUfo
instance:private Ufo _ufo1;
4. Add the following lines of code before the end of the
Initialize
method to create anUfo
instance and add this actor to the game:_ufo1 = new Ufo(this, Scene); AddActor(_ufo1);
5. Build and run the solution. The default web browser will appear displaying the two spaceships, and an UFO made of bricks moving through the 3D space, as shown in the following picture:
6. Click on the web browser's viewport to activate its focus. Move the mouse left and right. You will see that the camera that targets the spaceships and the new UFO rotates as the mouse is moved. Use the cursor movement keys to control the camera. Remember that you can also use your gamepad...