Space Engineers How to Make NPC in Game + Script

Space Engineers How to Make NPC in Game + Script 1 - steamsplay.com
Space Engineers How to Make NPC in Game + Script 1 - steamsplay.com

Creating a new NPC creature for Space Engineers.
 
 
How to make a unique non-player character and configure it for spawning in the game.
 
 

Introduction

In order to begin here, you will need to be familiar with some character modelling basics. There are lots of good tutorials for modelling & rigging character and creatures as well as some free resources available to all.
 
For the purposes of this tutorial, you can use my rig and model available with source files here.
 
 
hyper link for MOD
 
 
Tutorial image
 
 
 

Creature with skeleton

Once you have your idea and model it has to have a skeleton. Keen models use CAT rigs which I find easy to work with but any rig will work as long as you can bake your animations with it.
 
 
I tend to use 3ds max for my creatures but you can use whatever software you are comfortable using as long as you can create an FBX file or have a plugin to produce a character type MWM file.
 
 
3ds rig image
 
 
A keep point is that vertexes must have associated weights or the model will fail to appear there will likely be no error just an invisible character.
 
 
Heat map image
 
 
 

5 basic animations

Bot behaviours are limited to a select number of animations each one has to be defined in with an Animation sbc file, the minimum animations required are
 
Idle
 
Walk
 
Run
 
Attack
 
Dead
 
the extra ones for extra for spider behaviour bot
 
Burrow & deburrow
 
 
How to make an animation tutorial here: Soon ™
 
 
Choose a unique subtype or override an existing one
 
 

 <Animation>
 <Id>
 <TypeId>AnimationDefinition</TypeId>
 <SubtypeId>IdleSpider1</SubtypeId> 
 </Id>

 
only used for emotes
 
 

 
 <DisplayName>Idle1</DisplayName>
 <Description>Idle1</Description>
 <Icon>Textures\GUI\Icons\Fake.dds</Icon>

 
Path to baked animation file
 
 

 
<AnimationModel>Models\Characters\Animations\Creatures\Spider\spider_idle_1.mwm</AnimationModel>
 <ClipIndex>0</ClipIndex>

 
Areas of influence change to correspond with animation controller layer masking
 
 

 
 <InfluenceArea>Body</InfluenceArea> 

 
Use false for charicter control true for emotes
 
 

 
 <Public>false</Public> 

 
set to match skeleton variable in character sbc to filter only available animations
 

 

 
 <SupportedSkeletons>Arachnid</SupportedSkeletons>
 </Animation>

 

 
 
 

Sounds for your creation

You can add additional life to your creations with sounds. Each sound to be defined in an audio sbc file. Space engineers need to use a particular file type and format follow the tutorial below for more info: Sound Tutorial By enenra – [github.com] 
 
 
The sounds you can edit for a bot are
 

  • Motion/footsteps
  • Attack
  • Death
  • Pain

Each sound effect subtype is linked to the character within the character sbc file by using these lines and adding the subtype of your own sounds
 
 

 <MovementSoundName>subtype</MovementSoundName>
 <PainSoundName>subtype</PainSoundName>
 <DeathSoundName>subtype</DeathSoundName>

 
The attack sound is separate in the bot sbc
 
 

 <AttackSound>subtype</AttackSound>

 
 
 

Character SBC

This sbc file is the main connection for your creation with the game once you have a valid MWM file the rest of the character is set here, for a playable character there are move variables that are bot needed for a bot
 
 
subtype and of bot keep same as subtype to reduce confusion unless playable character
 
 

 <Character>
 <Id>
 <TypeId>MyObjectBuilder_Character</TypeId>
 <SubtypeId>Space_Wolf</SubtypeId> 
 </Id>
 <Name>Space_Wolf</Name> 

 
subtype of animation controller to be used
 
 

 <AnimationController>Wolf</AnimationController> 

 
Path to rigged model file
 
 

 <Model>Models\Characters\Wildlife\Wolf\Wolf01.mwm</Model> 

 
subtype of sound to play upon death
 
 

 <DeathSoundName>BotWolfDeath</DeathSoundName>

 
false if walking animation if not a loop
 
 

 <LoopingFootsteps>true</LoopingFootsteps> 

 
The material type will give different particle effects e.g. metal hit vs organic hit. Options come from physical materals sbc
 
 

 <PhysicalMaterial>Wolf</PhysicalMaterial>

 
Weight of bot in kilograms
 
 

 <Mass>20</Mass>

 
time in milliseconds dead body will stay for looting
 
 

 <LootingTime>300</LootingTime>

 
Skeleton type to match animation, options of Arachnid, Humanoid and Tetrapod_simple
 
 

 <Skeleton>Tetrapod_simple</Skeleton> 

 
name of bone assocated with top of spine
 
 

 <SpineBone>Wolf_Spine_3</SpineBone>

 
if controlled by player true will allow switching between views
 
 

 <EnableFirstPersonView>false</EnableFirstPersonView> 

 
Assign subtypes of your animations to match up the controller versions
 
 

 <AnimationMappings>
 <Mapping Name="Idle" AnimationSubtypeName="IdleWolf1" />
 <Mapping Name="Run" AnimationSubtypeName="RunWolf" />
 <Mapping Name="Walk" AnimationSubtypeName="WalkWolf" />
 <Mapping Name="Attack" AnimationSubtypeName="AttackWolf" />
 <Mapping Name="Died" AnimationSubtypeName="DiedDeer" />
 </AnimationMappings>

 
setting if character is useable by player false if bot true if to appear in list of available suits
 
 

 <UsableByPlayer>false</UsableByPlayer> 

 
set to true if bot is to broadcast signal
 
 

 <VisibleOnHud>false</VisibleOnHud> 

 
size of inventory and allowed mass of loot
 
 

 <Inventory>
 <InventoryVolume>1</InventoryVolume>
 <!-- in m3 ! -->
 <InventoryMass>50</InventoryMass>
 </Inventory>

 
additional components associated with character her you can add is optional loot bag component.
 
 

 <!-- ENABLED COMPONENTS -->
 <EnabledComponents>RagdollComponent</EnabledComponents>

 
name of bone assocated with “head” and the bone at the root of the model
 
 

 <!-- BONES -->
 <HeadBone>Wolf_Head</HeadBone> 
 <ModelRootBoneName>DEER_dummy</ModelRootBoneName> 

 
Different movement types and speeds the bot will use
 
 

 <!-- Character control -->

 <VerticalPositionFlyingOnly>false</VerticalPositionFlyingOnly>
 <UseOnlyWalking>false</UseOnlyWalking>


 <MaxSlope>65</MaxSlope>
 <MaxSprintSpeed>14</MaxSprintSpeed>

 <MaxRunSpeed>11</MaxRunSpeed>
 <MaxBackrunSpeed>8</MaxBackrunSpeed>
 <MaxRunStrafingSpeed>0</MaxRunStrafingSpeed>

 <MaxWalkSpeed>1</MaxWalkSpeed>
 <MaxBackwalkSpeed>1</MaxBackwalkSpeed>
 <MaxWalkStrafingSpeed>0</MaxWalkStrafingSpeed>

 <MaxCrouchWalkSpeed>1</MaxCrouchWalkSpeed>
 <MaxCrouchBackwalkSpeed>1</MaxCrouchBackwalkSpeed>
 <MaxCrouchStrafingSpeed>0</MaxCrouchStrafingSpeed>

 
Position and size of the main sphere used for collision.
 
 

 <CharacterHeadSize>0.35</CharacterHeadSize>
 <CharacterHeadHeight>0.0</CharacterHeadHeight>
 <CharacterCollisionScale>0.8</CharacterCollisionScale>

 
Force the bot can apply towards other characters or objects
 
 

 <MaxForce>500</MaxForce>

 
 
 

Character sbc continued

Assignment of collision capsules surrounding bone “sets” collision radius can be increased to match the scale of the bot.
 
 
each set has a name and consists of a top one and a secondary bone
 
 

 <BoneSet>
 <Name>Body</Name>
 </BoneSet>

 <RagdollBonesMappings>
 <BoneSet>
 <Name>Wolf_Head</Name>
 <Bones>Wolf_Head Wolf_HeadBone007</Bones>
 <CollisionRadius>0.25</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_Neck_2</Name>
 <Bones>Wolf_Head Wolf_Neck_2</Bones>
 <CollisionRadius>0.25</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_Neck_1</Name>
 <Bones>Wolf_Neck_2 Wolf_Neck_1</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_Ribcage</Name>
 <Bones>Wolf_Ribcage Wolf_Spine_3</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_Tail_1</Name>
 <Bones>Wolf_Pelvis Wolf_Tail_1</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_Tail_2</Name>
 <Bones>Wolf_Tail_1 Wolf_Tail_2</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_Tail_3</Name>
 <Bones>Wolf_Tail_2 Wolf_Tail_3</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_Leg_2</Name>
 <Bones>Wolf_L_Leg_1 Wolf_L_Leg_2</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_Leg_Palm</Name>
 <Bones>Wolf_L_Leg_2 Wolf_L_Leg_Palm</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_Leg_Digit01</Name>
 <Bones>Wolf_L_Leg_Palm Wolf_L_Leg_Digit01</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_Leg_2</Name>
 <Bones>Wolf_R_Leg_1 Wolf_R_Leg_2</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_Leg_Palm</Name>
 <Bones>Wolf_R_Leg_2 Wolf_R_Leg_Palm</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_Leg_Digit01</Name>
 <Bones>Wolf_R_Leg_Palm Wolf_R_Leg_Digit01</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_FrontLeg_1</Name>
 <Bones>Wolf_L_FrontLeg_Collarbone Wolf_L_FrontLeg_1</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_FrontLeg_2</Name>
 <Bones>Wolf_L_FrontLeg_1 Wolf_L_FrontLeg_2</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_FrontLeg_Palm</Name>
 <Bones>Wolf_L_FrontLeg_2 Wolf_L_FrontLeg_Palm</Bones>
 <CollisionRadius>0.05</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_L_FrontLeg_Digit</Name>
 <Bones>Wolf_L_FrontLeg_Palm Wolf_L_FrontLeg_Digit01</Bones>
 <CollisionRadius>0.05</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_FrontLeg_1</Name>
 <Bones>Wolf_R__FrontLeg_Collarbone Wolf_R__FrontLeg_1</Bones>
 <CollisionRadius>0.2</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_FrontLeg_2</Name>
 <Bones>Wolf_R__FrontLeg_1 Wolf_R__FrontLeg_2</Bones>
 <CollisionRadius>0.1</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_FrontLeg_Palm</Name>
 <Bones>Wolf_R__FrontLeg_2 Wolf_R__FrontLeg_Palm</Bones>
 <CollisionRadius>0.05</CollisionRadius>
 </BoneSet>
 <BoneSet>
 <Name>Wolf_R_FrontLeg_Digit</Name>
 <Bones>Wolf_R__FrontLeg_Palm Wolf_R__FrontLeg_Digit01</Bones>
 <CollisionRadius>0.05</CollisionRadius>
 </BoneSet>
 </RagdollBonesMappings>

 
 
The animation to state to play immediately upon spawn
 
 

 <InitialAnimation>IdleWolf1</InitialAnimation>

 
The physics shape to be used after death animation for the remaining body.
 
 

 <DeadBodyShape> 
 <BoxShapeScale x="0.8" y="0.10" z="1.75"/>
 <RelativeCenterOfMass x="0" y="0" z="0"/>
 <RelativeShapeTranslation x="-1.5" y="-0.7" z="0"/>
 <Friction>20</Friction>

 
</DeadBodyShape>
 
variable to change if bot is capable of moving in multiple planes options of “OneAxis” and “Full”
 
 

 <RotationToSupport>OneAxis</RotationToSupport>

 
additional setting of height of collision in metres
 
 

 <CharacterCollisionHeight>1.1</CharacterCollisionHeight>
 </Character>

 
 
 

Bot SBC

This file sets up the type of bot and additional variables unique for NPC’s
 
setup a subtype of bot to be used this can be the same subtype as the character definition
 
 

 <Bots>
 <Bot xsi:type="MyObjectBuilder_AnimalBotDefinition">
 <Id>
 <TypeId>MyObjectBuilder_AnimalBot</TypeId>
 <SubtypeId>Wolf</SubtypeId>
 </Id>
 <DisplayName>DisplayName_Bots_Deer</DisplayName>

 
Icon (not used will generate error as deer doesn’t exist)
 
 

 <Icon>Textures\GUI\Icons\SpawnDeer.dds</Icon> 

 
name of character from character sbc
 
 

 <BotModel>Space_Wolf</BotModel> 

 
subtype of behavior to use, choose from wolf/animal/spider to match behavor sbc
 
 

 <BotBehaviorTree Subtype="WolfBehavior" /> 
 <!-- Which behavior tree to use -->
 <BehaviorType>Wolf</BehaviorType> 

 <!-- Which actions (and logic) class to use -->
 <TargetType>Wolf</TargetType>
 

 
variables related to what happens after death, for different loot use subtype of custom loot definition which can be defined using entity container file
 
 

 <Public>true</Public>
 <AvailableInSurvival>false</AvailableInSurvival>
 <RemoveAfterDeath>true</RemoveAfterDeath>
 <InventoryContentGenerated>true</InventoryContentGenerated>
 <InventoryContainerTypeId>
 <TypeId>ContainerTypeDefinition</TypeId>
 <SubtypeId>WolfLoot</SubtypeId>
 </InventoryContainerTypeId>

 
enemy creatures use SPID faction but this can be customised but this can cuse other bots to become valid targets
 
 

 <FactionTag>SPID</FactionTag>

 
duration from the start of the attach animation before damage is applied in millisections
 
 

 <AttackLength>1000</AttackLength> 

 
area of effect the damage will take in metres
 
 

 <AttackRadius>0.5</AttackRadius> 

 
amount of HP damage to cause
 
 

 <CharacterDamage>12</CharacterDamage> 

 
amount of damage to cause to components
 
 

 <GridDamage>0</GridDamage> 

 
if bot should see grids or other characters are valid targets use true/false
 
 

 <TargetGrids>false</TargetGrids> 
 <TargetCharacters>true</TargetCharacters> 

 
subtype of audio definition to be triggered when attacking
 
 

 <AttackSound>ArcBotWolfAttack</AttackSound> 

 
 
 

Behaviour type

Behaviour types you can choose from each provide a different way that the npc will operate.
 

  • “Wolf” – vanilla
  • “Spider” – vanilla
  • “Passive herd” – from mod behaviour
  • “Passive investigate” – from mod behaviour

 
 
 

Animation controller

for more advanced users you can create your own animation controller especially if your trying to create additional steps into the animations.
 
 
Keen provides a program to edit these files with a program to edit and create these files. with more information here: https://steamcommunity.com/sharedfiles/filedetails/?id=682814593 – [steamcommunity.com] 
 
 
 

Stats sbc

 
 
 

Planet generator SBC

 
 
 

Testing – there’s a mod for that!

 
 

Written by Chipstix213

 
 
This is all for Space Engineers How to Make NPC in Game + Script hope you enjoy the post. If you believe we forget or we should update the post please let us know via comment, we will try our best to fix how fast is possible! Have a great day!
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*