官术网_书友最值得收藏!

Registering a new AI class

At the heart of every character in CRYENGINE is the IActor interface. It provides the mechanism for objects to have AI. When we refer to a player or an AI, we are really referring to something called an actor. An actor is responsible for containing and managing all the logic that will be used to bring an object to life. This can range from being an animal companion, an AI character, or any other game object whose purpose is to represent living objects. Since GAS is a very simple side-scroller, we will not be using CRYENGINE's AI system. However, we will use CRYENGINE's IActor interface since our character is a living object. There is not much difference between our player and the AI; the only difference is how they shoot and who they shoot at. This allows us to reuse the CPlayer class for our AI, and simply register it under a different class name.

Open the CGASGame.cpp file and navigate to the RegisterGameObjects() method. Re-register the CPlayer class under the name AI. It should look like this:

//Registers The AI.
REGISTER_FACTORY( m_pGameFramework, "AI", CPlayer, true );

Notice that we reuse the CPlayer implementation and just register it under a different class name AI. This will create another entity class called AI that uses the exact same code as the CPlayer class.

主站蜘蛛池模板: 大城县| 商洛市| 甘泉县| 光泽县| 屏边| 江口县| 大连市| 双牌县| 海兴县| 鄂州市| 师宗县| 新巴尔虎右旗| 高邮市| 五指山市| 西昌市| 海原县| 青龙| 会宁县| 朝阳区| 屏东市| 竹北市| 时尚| 潜山县| 武汉市| 云和县| 南城县| 宁德市| 浮山县| 河间市| 玉林市| 伊川县| 商都县| 纳雍县| 大名县| 洛宁县| 德令哈市| 眉山市| 夹江县| 洞头县| 淅川县| 阿克陶县|