Skip to content

Instantly share code, notes, and snippets.

@AndreaCatania
Last active July 7, 2019 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreaCatania/c644a0d7085e394eb725d531d9888345 to your computer and use it in GitHub Desktop.
Save AndreaCatania/c644a0d7085e394eb725d531d9888345 to your computer and use it in GitHub Desktop.
Useful information of amethyst game engine

Coords

The coordinate system is +Y up, and the camera looks toward -Z

Components

A component must be registered before used. It is registerd automatically in the setup function by the System trait. If, for any reason, the component is not yet used by any system, you can register it using the below code, and thus avoid panics.

world.register::<MyComponent>()

Meshes

To create a new primitive mesh is possible to use the following helper:

use amethyst::renderer::Shape;
 let sphere_mesh_data : types::MeshData = Shape::Sphere(32, 32)
                    .generate::<(Vec<Position>, Vec<Normal>, Vec<Tangent>, Vec<TexCoord>)>(None)
                    .into();

Is it also important to notice that to be visualized the mesh must have a valid material attached to it.

Entities

Is possible to Add, Remove, entities within the systems. Is also possible Remove or Add components to a particular entity inside a system.

https://github.com/AndreaCatania/amt_tests/blob/master/cubes/src/impulse_system.rs#L42-L53

Of curse is possible to do so even out of the systems, but an extra step is required. You must take the compoent Storages or use the below code:

WriteStorage::<Component>::fetch(&world).insert(entity, component)
WriteStorage::<Component>::fetch(&world).remove(entity)

Custom join filtering

Is possible to populate a BitSet with entity indices and use it to filter a storage. This is a good example on how do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment