User Tools

Site Tools


besiege:modding:example-guides:creatingentity

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
besiege:modding:example-guides:creatingentity [2018/06/18 16:46]
von
besiege:modding:example-guides:creatingentity [2018/07/10 16:23] (current)
spaar
Line 8: Line 8:
  
 ===== Getting Started ===== ===== Getting Started =====
- 
-Note: You can skip/​automate many of the first steps using the ''​[[..:​moddevelopment#​shortcuts|createentity]]''​ console command. 
  
 An entity is defined using an XML file within the mod's directory. An entity is defined using an XML file within the mod's directory.
  
-  * Create the entity ​.xml file (e.g. ''​SomeEntity.xml''​).+Create ​that file using the ''​[[..:​moddevelopment#​shortcuts|createentity]]'' ​console command, i.e. start the game, open the console, and execute ''​createentity <mod name> <entity name>''​.
  
-''​xml <​Entity>​ <​Name>​Some Entity</​Name>​ </​Entity>''​+This will create a basic XML file and add a reference to it to the manifest.
  
-  * Reference the entity in the mod manifest. +===== Defining the entity'​s properties =====
- +
-''​xml <Mod> ... <​Entities>​ <Entity path="​SomeEntity.xml"​ /> </​Entities>​ </​Mod>''​ +
- +
-===== Defining the entity'​s ​basic properties =====+
  
 The various elements of the entity'​s XML file are used to define how the entity behaves and looks in-game. For a full reference, see [[..:​xml-elements:​Entity|Elements of an Entity]]. The various elements of the entity'​s XML file are used to define how the entity behaves and looks in-game. For a full reference, see [[..:​xml-elements:​Entity|Elements of an Entity]].
  
-  * Assigning an ID+=== Assigning an ID ===
  
 The ID must uniquely identify the entity among all entities in the same mod; the easiest way to handle this is to just use sequential IDs (1, 2, 3, ...). The ID must uniquely identify the entity among all entities in the same mod; the easiest way to handle this is to just use sequential IDs (1, 2, 3, ...).
  
-''​<​ID>​1</​ID>​''​+<code xml><​ID>​1</​ID>​</​code>​
  
-  * Some basic properties+=== Some basic properties ​===
  
-''​xml <​Category>​Buildings</​Category>​ <Scale canScale="​true"​ uniformScale"​false"​ />''​+<​code ​xml
 +<​Category>​Buildings</​Category>​ 
 +<Scale canScale="​true"​ uniformScale"​false"​ /> 
 +</​code>​
  
 These are just examples, there are more properties that can be used. These are just examples, there are more properties that can be used.
  
-===== Defining the entity'​s visuals =====+=== Visuals ​===
  
 The visuals of an entity are defined using the ''​Mesh''​ and ''​Texture''​ elements. In addition, mods also need to supply an image to be used as the entity'​s icon in the level editor UI. These are all used with the resource system, which means they first need to be defined in the mod manifest. The visuals of an entity are defined using the ''​Mesh''​ and ''​Texture''​ elements. In addition, mods also need to supply an image to be used as the entity'​s icon in the level editor UI. These are all used with the resource system, which means they first need to be defined in the mod manifest.
  
   * Add the mesh and texture to the mod manifest.   * Add the mesh and texture to the mod manifest.
- +<​code ​xml
-''​xml <Mod> ... <​Resources>​ <Mesh name="​some-entity-mesh"​ path="​SomeEntity.obj"​ /> <Texture name="​some-entity-tex"​ path="​SomeEntity.png"​ /> <Texture name="​some-entity-icon"​ path="​SomeEntity.png"​ /> </​Resources>​ </​Mod>​''​+<Mod> 
 +    ​... 
 +    ​<​Resources>​ 
 +        ​<Mesh name="​some-entity-mesh"​ path="​SomeEntity.obj"​ /> 
 +        ​<Texture name="​some-entity-tex"​ path="​SomeEntity.png"​ /> 
 +        ​<Texture name="​some-entity-icon"​ path="​SomeEntity.png"​ /> 
 +    ​</​Resources>​ 
 +</​Mod>​ 
 +</​code>​
  
   * Reference the mesh and texture in the entity file.   * Reference the mesh and texture in the entity file.
  
-''​xml <​Entity>​ ... <Mesh name="​some-entity-mesh"​ /> <Texture name="​some-entity-tex"​ /> <Icon name="​some-entity-icon"​ /> </​Entity>​''​+<​code ​xml
 +<​Entity>​ 
 +    ​... 
 +    ​<Mesh name="​some-entity-mesh"​ /> 
 +    ​<Texture name="​some-entity-tex"​ /> 
 +    ​<Icon name="​some-entity-icon"​ /> 
 +</​Entity>​ 
 +</​code>​
  
 Remember that resource paths are always relative to the ''​Resources/''​ directory, not the mod directory itself. Remember that resource paths are always relative to the ''​Resources/''​ directory, not the mod directory itself.
Line 55: Line 67:
 There is an additional option to transform the mesh in case it is incorrectly positioned, rotated or scaled, see [[..:​xml-elements:​Common#​mesh|Mesh]]. There is an additional option to transform the mesh in case it is incorrectly positioned, rotated or scaled, see [[..:​xml-elements:​Common#​mesh|Mesh]].
  
-===== Colliders ​=====+=== Colliders ===
  
 Every entity needs to have colliders for physics. Every entity needs to have colliders for physics.
Line 63: Line 75:
   * Define the entity'​s colliders   * Define the entity'​s colliders
  
-''​xml <​Entity>​ ... <​Colliders>​ <​BoxCollider>​...</​BoxCollider>​ <​SphereCollider>​...</​SphereCollider>​ ... </​Colliders>​ </​Entity>​''​+<​code ​xml
 +<​Entity>​ 
 +    ​... 
 +    ​<​Colliders>​ 
 +        ​<​BoxCollider>​...</​BoxCollider>​ 
 +        ​<​SphereCollider>​...</​SphereCollider>​ 
 +        ​... 
 +    ​</​Colliders>​ 
 +</​Entity>​ 
 +</​code>​
  
 For more information on the collider shapes available and how to use them, see [[..:​xml-elements:​Common#​colliders|Colliders]]. For more information on the collider shapes available and how to use them, see [[..:​xml-elements:​Common#​colliders|Colliders]].
besiege/modding/example-guides/creatingentity.txt · Last modified: 2018/07/10 16:23 by spaar