Collisions

From Space Engineers Wiki
Jump to navigation Jump to search
beginner
Learnings

How to set up a collision model.

How to troubleshoot a collision model.

How to create models in Blender.

How to bring models into the game.

Overview

Collisions for entities in Space Engineers are created in Blender and then exported to a .hkt-file format to be integrated into the final .mwm-files the physics engine of the game (Havok) uses. There are a number of requirements for how those collisions are set up, which this tutorial aims to cover.

Create Collision Models

Step 1: Create a Collision Collection.

Create a Collision-collection and assign it to either the Main-collection of your scene or one of the BSx (Build Stage) collections. Build Stages will default to use the Main-collection’s collisions if none are defined for them.

SEUT creates a default Collision-collection and assigns it to the Main-collection.

While SEUT supports assigning individual collision collections to the Main-collection and each BS-collection, there is currently a bug in Space Engineers that prevents more than one collision model per block from working correctly (collisions are only updated on a reload of the world). As such, it is not recommended to use this feature at the moment. A fix is somewhat unlikely, as vanilla Space Engineers does not use this mechanic in any of its blocks.
Step 2: Create Collision Objects.

Create objects and place them inside the Collision-collection. These objects should generally be simple geometric shapes and your aim is to use as little separate objects as possible. However, make sure that your objects are all convex - never concave - as Havok does not support concave objects.

Concave shapes will have their “gaps” filled in.
Concave shapes will have their “gaps” filled in.
Collision objects that are concave will be simplified during conversion into the HKT format to not have any concave section. You can only achieve concave collisions by creating multiple collision objects and arranging them accordingly.
Space Engineers only supports up to 10 collision objects. Any object above that limit will be ignored and generate an error message.
All collision objects must be within the bounds set by the bounding box. If collision objects extend beyond the block bounds, the collisions might be replaced by a default collision box in line with the bounding box. They will also cause strange interactions with other entities like characters and projectiles, so you should avoid it always.
Step 3: Assign Rigidbodies.

Select the first of your collision objects and in its Properties under Physics Properties, assign it a Rigid Body. Then, select a shape which can reasonably represent your collision. If at all possible, you’ll want to use anything but Convex Hull, as they are more performant, though often Convex Hull is the only viable option. You cannot use Cone, Mesh or Compound Parent as Havok does not recognize them. Repeat this for all your collision objects inside the Collision-collection.


Seut collisions tutorial 2.png Seut collisions tutorial 3.png

The different shapes that can be set for Rigid Bodies have various performance impacts. The performance impacts from largest to smallest are:

Convex Hull > Box > Cylinder > Capsule > Sphere

You should aim to optimize your collision model accordingly.
Rigid Body shapes cannot be rotated. They have only one facing and will always face that way, no matter whether you rotate the collision mesh or not. As a result, though some shapes look like they may be perfect for, say, Cylinder, you might find that it actually cannot be used.
Rigid Bodies will not update properly when you change the collision object they’re attached to. Please make sure that you apply transformations to your collision objects before adding the rigidbody, and that you recreate the Rigid Body after changing the collision object’s shape, position, rotation, etc.
Step 4: Test ingame.

After you’ve exported your block, it’s time to test the collisions ingame. Make sure to do so in a Singleplayer world set to Offline, as some dev tools might not be available otherwise. Once loaded into a savegame, place your item or block and then hit F11. In the menu, enable Debug Draw and then Physics Primitives. Note that you might have to toggle Physics Primitives on and off a couple times for it to start working.


Seut collisions tutorial 4.png

You will now see light blue and red shapes representing the collisions of all entities ingame. Red denotes Convex Hull, blue Box, white Sphere, orange Cylinder and yellow Capsule. Use these to verify the shapes and as a guide to make adjustments in Blender.

Troubleshooting

Collisions are not accurate ingame

Solution

There are several different reasons why this may be the case:

  1. Is your collision shape concave? Remember: Concave shapes will have their “holes” filled in. You have to replicate the shape using several convex collision objects instead.
  2. Does your collision go outside the Bounding Box of your block? Space Engineers does not allow this and may revert your collision back to a box collision.
  3. Is the collision ingame just slightly larger than what you have in Blender? This seems to be a weird particularity about the conversion process into .hkt. You’ll have to make your collision shapes slightly too small in Blender to compensate. (This is also what Keen has done when they adjusted armor collisions to not clang out so much in Spring 2021.)
  4. Do you use individual collisions for your BS and Main models? While SEUT supports assigning individual collision collections to the Main-collection and each BS-collection, there is currently a bug in Space Engineers that prevents more than one collision model per block from working correctly (collisions are only updated on a reload of the world). As such, it is not recommended to use this feature at the moment. A fix is somewhat unlikely, as vanilla Space Engineers does not use this mechanic in any of its blocks.

Changing collisions has no effect ingame

Solution

That issue is commonly caused by either of these two:

  1. Did you apply transformations, then remove and re-add the Rigid Body to your collision object after editing it? Rigid Bodies are not updated properly with the change in the collision object they’re attached to. As a result, you have to make sure to apply transformations and re-add the Rigid Body.
  2. Did you completely restart (not reload) the game after changing the collision? Space Engineers only loads collision information on game start. If you don’t restart the game and only reload (or not even that), the collision will not be updated ingame.

Special Note: Collisions on Subparts

Solution

Unless the vanilla Space Engineers blocks of the same type also have subparts and collisions on their subparts, subparts do not support collisions at all. That being said, here are some notes on collisions in specific block types:

  • Hangar Doors Hangar Doors commonly have two issues: First, when opening and closing with a small grid touching them, they can cause that small grid to be catapulted away. Second, when the collisions on the moving subparts are being shot, or interacted with otherwise, there is a chance that they start drifting away from the visual position of the subpart. This problem can be solved by doing the following:
    • Use Convex Hull for the collider of the base block.
    • Rotate the empty for the first hangar door subpart by 180° on the Z Axis.
    • Use the same collider type for all hangar door subpart collisions.