r/Amethyst • u/erlend_sh • Jun 06 '19
r/Amethyst • u/Boiethios • Jan 25 '19
Did you see this post about embedded WASM?
The post: https://www.reddit.com/r/rust/comments/ajfrf0/embedding_webassembly_in_your_rust_application/
This would be cool to do the scripting like this in Amethyst. No language imposed.
r/Amethyst • u/ABitInAByte • Jul 20 '20
Creating a UI by code
Hey, I am trying to make my own game, and I wanted to learn Rust at the same time. So I am loving using Amethyst for the most part. Though I am having a hard time with the UI components. I want to make a starting menu (This will also allow me top load components in the background). However, all the examples I see using the UI crate use a configuration file. I understand why one would want to do this and it makes it easy to change in the future. But for my purposes (wanting to learn what is happening) I want to do it in code.
I can't find any example of the UI crate, implementing something in code. Could someone please help me out? any help is greatly appreciated!!
r/Amethyst • u/excuse-my-lisp • Sep 28 '20
Current state of Amethyst's editor support?
I recently tried starting up an Amethyst project with a non-technical friend, but while I found the engine itself fine to write code for, the lack of an editor makes it infeasible to have a non-technical user create a complex level and UI, and makes it very slow and painful even for a technical user.
The amethyst-editor project hasn't been updated in over a year, and has a deprecation notice that states that all future work is going to be on the atelier-editor; the link to this page simply returns a 404.
I wouldn't be opposed to putting some time in to helping out the development of an editor, but I don't even know where to start. The editor-core project would provide a useful starting point, but it looks like it fell out of development when it changed to support the missing atelier editor; starting from scratch is possible, but would take a lot of work and would throw away what looks to be a good deal of existing code.
r/Amethyst • u/[deleted] • Feb 08 '19
Xaeroxe on the future of nitric, igneous, specs, and amethyst
r/Amethyst • u/blackscales18 • May 12 '20
Coding phases of turns
I'm developing a small collectible card game using amethyst and I need a way to move through a set of phases in a specific order every turn, with events triggering on start and end and various points. States seem like a good option, but is that an appropriate use for them, or would i be better off using a system of some sort. Thanks for any help, I'm new to rust and amethyst.
r/Amethyst • u/-Hovercorn- • Apr 13 '20
Multiple InputHandler Contexts?
Hi!
I read up the docs on input handling, and was successfully able to import my custom bindings (StringBindings) from .ron. When adding new bindings (Actions), I eventually ran into the ComboAlreadyBound BindingError.
Essentially, I wanted to have the same key provide different actions depending on context: pressing [Key(W)] in one context might move the player up ("move_up"), but in another context (inventory menu) it might select an item ("select_item_1").
A scaled-down example of what gave the error when importing from bindings.ron:
// ---- Movement Context ---- //"move_up": [
[Key(W)]
],"move_down": [
[Key(S)]
],
...
// ---- Inventory Context ---- //
"select_item_1": [
[Key(W)]
],"select_item_2": [
[Key(LControl)]
],
...
The above would give me an error message saying "move_up" was already bound. But since it's a different action, I assumed there would be no conflict.
So, is there a way to provide different "input contexts" to the key bindings so that the same exact key combinations ("W",in this case) can correspond to different actions? I was able to figure it out for ggez, but can't get it right here.
Thanks.
r/Amethyst • u/-Hovercorn- • Apr 17 '20
Custom Input Bindings Disrupt UI/Input Events
While tinkering with Amethyst's UI functionality (namely hover and click functionality on buttons), I noticed that my UI events weren't registering at all. In fact, my InputEvents weren't working, either. After some trial and error, I found the issue to be custom BindingTypes.
In other words, using custom BindingTypes (vs the default StringBindings) interferes with proper UiEvent and InputEvent event handling, such as in a SimpleState's handle_event method or a system's run method.
I was able to reproduce the issue by:
1.) Using the following code [LINK] as main.rs, which is essentially a derivation of code from Amethyst's examples.
2.) using the custom bindings (MovementBindings) with the InputBundle, as per the "How to Define Custom Control Bindings" section of the Amethyst documentation [LINK].
Now, the UI elements (buttons, text inputs, etc) can no longer be interacted with , nor will the following messages from Example's handle_event() be seen:
"[HANDLE_EVENT] You just interacted with a ui element: {:?}"
"Input Event detected: {:?}."
The same issue occurs even when:
no UI elements are loaded
no custom bindings loaded from file (but still used by the
InputBundle)
If StringBindings are used instead, everything works fine. Just changing:
.with_bundle(InputBundle::<MovementBindingTypes>::new())?
to.with_bundle(InputBundle::<StringBindings>::new())?
Results in expected behavior.
Any ideas as to why this occurs? I can't figure out how to get custom bindings to work without disrupting UI functionality.
Thanks for your help.
EDIT: the UI example.ron I used, which was pared down from Amethyst's UI example: [LINK]
r/Amethyst • u/dnew • Apr 19 '20
Where to learn multi-entity type systems?
What I mean is, things like the physics system, or awareness (can entity X see entity Y?) or anything that naively would involve an N2 iteration over all entities.
That is, I'm looking for a convenient way of understanding how to use an ECS to do things that would normally be done with space partitioning. Is there a good video or blog or something that anyone would recommend?
Also, while I'm here, I'm curious how one might handle something like an open-world system, where portions of a level would need to be unloaded and reloaded, perhaps with some scripts still running.
I'm good at programming, have written a few small games, read and understood the current Amethyst book. But I never really got into advanced 3D games where size or performance ever came into question, and I'm curious how modern engines actually handle that. Even if it's not amethyst.
Thanks in advance for any suggestions!
r/Amethyst • u/lberrymage • Apr 23 '20
How does one clamp a `UnitQuaternion`s rotation along an axis?
UPDATE: I now have a working implementation which solves my problem perfectly. It is in its own section below the original post which was kept for any whom it may concern.
I have a Camera being controlled by a custom CameraRotationSystem which is derived from Amethyst's FreeRotationSystem. My goal is to have a basic first-person camera which clamps its local x-axis rotation between -90 and 90 degrees (straight up and straight down). This to prevent "backflipping." My current implementation creates two UnitQuaternions, one pointing up and one pointing down, and checks if the current rotation is more than PI/2 radians away from either of them. However, this is never the case since the UnitQuaternion.angle_to() function always finds the smallest angle between UnitQuaternions (as it should). To clarify, I understand why this doesn't work, but I don't know what else to try.
How should I go about solving this problem? I have avoided Euler angles because I don't want to cause gimbal lock, but I'm open to any suggestions which use Euler angles that can completely avoid gimbal lock. Also, the provided code only shows the logic for x-axis rotation; y-axis rotation is unlimited.
Thank you for reading my long explanation, and again if you can help! Below is the code for the run method of the CameraRotationSystem I currently have. I appreciate any and all input you may have.
fn run(&mut self, (events, hide, focus, tag, mut transform): Self::SystemData) {
for event in events.read(&mut self.event_reader) {
if focus.is_focused && hide.hide {
if let Event::DeviceEvent { ref event, .. } = *event {
if let DeviceEvent::MouseMotion { delta: (x, y) } = *event {
for (transform, _) in (&mut transform, &tag).join() {
// Treat `MouseMotion` delta as rotation in degrees
// Use the mouse motion delta to rotate up and down
transform.append_rotation_x_axis((-y as f32).to_radians());
// The limiting `UnitQuaternion`s which will be checked against
let down = UnitQuaternion::from_axis_angle(&Vector3::x_axis(), -FRAC_PI_2);
let up = UnitQuaternion::from_axis_angle(&Vector3::x_axis(), FRAC_PI_2);
// Is the camera facing up and behind? (never true)
if transform.rotation().angle_to(&down) > PI {
// Keep camera from rotation further backwards
transform.face_towards(Vector3::new(0.0, 0.0, 1.0), Vector3::new(0.0, 1.0, 0.0));
// Is the camera facing down and behind? (never true)
} else if transform.rotation().angle_to(&up) > PI {
transform.face_towards(Vector3::new(0.0, 0.0, 1.0), Vector3::new(0.0, -1.0, 0.0));
}
/* --snip-- */
}
}
}
}
}
}UPDATE: I have found a solution. The code snippet and explanation lie below. A full working example can be found in my repository (you might want to add a couple println!()s to see better what's going on).
lazy_static! {
static ref DOWN: Vector3<f32> = -Vector3::y();
static ref UP: Vector3<f32> = Vector3::y();
}
if let DeviceEvent::MouseMotion { delta: (x, y) } = *event {
for (transform, _) in (&mut transform, &tag).join() {
// Create a vector facing forward relative to the camera
let forward = transform.rotation() * -Vector3::z();
// Treat `MouseMotion` delta as rotation in degrees
transform.append_rotation_x_axis(-math::clamp(
y.to_radians() as f32,
-forward.angle(&UP),
forward.angle(&DOWN),
));
// Rotation around y-axis, just for completion
transform.prepend_rotation_y_axis((-x as f32).to_radians());
}
}My original problem (in a nutshell) is that I was thinking of quaternions incorrectly. The rotation angle between two quaternions is not always the same as the rotation angle between two vectors with the same axes as those two quaternions. Remember, quaternions have rotation. Vectors do not. So the angle between two quaternions takes into account the rotation of those quaternions and attempts to find the single rotation which will make them line up exactly, rotation and all. If you don't care about or understand that bit, here's an explanation of the current code.
Amethyst (via winit) processes mouse input through deltas, so any clamping method used would have to clamp the delta instead of the final rotation. Otherwise, a large enough delta could cause the rotation to "jump over" the clamping boundary, bypassing restrictions and possibly ending in a broken/illegal position.
How do we clamp the delta though? We need to know how much of a delta would push the rotation to the boundary and then clamp the delta at that point. To find the angle to the boundary, nalgebra has a handy angle() function which returns the smallest angle between two vectors. We need to find the angle between our relatively forward vector and the constant UP and DOWN vectors. After doing so, all that's left is to clamp the given MouseDelta (converted to an angle) between the UP and DOWN vectors. Voilà! The camera is clamped!
r/Amethyst • u/TheTimegazer • Apr 20 '20
How do I spawn an entity with a texture at runtime?
Hi, I'm having trouble wrapping my head around certain aspects of Amethyst, and one of these is how to correctly deal with texture handles.
I get how to add an entity to the world while the game is running, as explained here, but I'm unsure as to how to add a texture handle component to it also.
In the pong tutorial, they go through this whole rigamarole loading a sprite from a sprite sheet into the on_start function of the game's main state, but it doesn't seem clear to me how I'd go about doing something similar in a system.
I see a couple obvious solutions
Do exactly the same thing, load the texture, acquire the handle, and use the handle.
This seems really expensive to do at runtime
Have the handle to the texture file be a Resource that is loaded as needed
It's not obvious how this would then be used in the main state
Any help on this regard?
r/Amethyst • u/[deleted] • Jul 08 '19
can use amethyst to create GUI software?
i know amethyst is a game engine. but i was wondering can make GUI software with it or just way too difficult/waste of time to do so.
Share your thoughts with me. if you have any experience with it, is good to hear from you.
Thanks
r/Amethyst • u/SantosLouisHalper • Sep 20 '19
display texture without spritesheet
I'm trying to just take a .png I created and display it in the window. I was going off this page in the book but was just getting a blank window. Some googling brought up this github issue which says that page is obsolete.
Is it possible to just show an image without creating a spritesheet?
r/Amethyst • u/flappyBug • Nov 01 '18
How to draw simple 2D shape in amethyst?
Is there a api to draw simple 2d shape like square or polygon?
r/Amethyst • u/[deleted] • Jan 23 '20
Need some help understanding what the Specs lifetime parameters are actually for.
This is probably partially just a general Rust question, but I'm asking specifically in the context of Amethyst and Specs. I apologize if something like this has been asked before.
I've been using Rust here and there for a few years now, and I understand all of its concepts fairly well, except for generic lifetimes. I understand them in the simple case (a function takes two references and returns one, which reference's lifetime does the returned reference have?), but not at all for practical cases.
There seem to be a family of types in Amethyst/Specs that have two lifetime parameters: Dispatcher, DispatcherBuilder, SystemBundle, etc. All of these eventually feed into Dispatcher:
pub struct Dispatcher<'a, 'b> {
stages: Vec<Stage<'a>>,
thread_local: ThreadLocal<'b>,
...
}Here are the definitions of Stage and ThreadLocal:
pub struct Stage<'a> {
groups: GroupVec<ArrayVec<[SystemExecSend<'a>; MAX_SYSTEMS_PER_GROUP]>>,
}
pub type SystemExecSend<'b> = Box<dyn for<'a> RunNow<'a> + Send + 'b>;
pub type ThreadLocal<'a> = SmallVec<[Box<dyn for<'b> RunNow<'b> + 'a>; 4]>;These types perplex me, because they simply add the lifetime parameters as trait bounds for RunNow trait objects.
My first question is: why even add them at all? What exactly would happen if these types were defined as:
pub type SystemExecSend = Box<dyn for<'a> RunNow<'a> + Send>;
pub type ThreadLocal = SmallVec<[Box<dyn for<'b> RunNow<'b>>; 4]>;My second question is: what is with the for<'a> Type<'a>? I've seen this syntax before and from what I recall it's some sort of shorthand.
My third question: What is stopping me from just using 'static for these parameters in my own code? The answer is clearly "nothing" because I went and tried it, and everything compiled just fine. Am I losing some sort of safety by doing this?
My fourth question: in my browsing of Rust forums, I've noticed that there seems to be a sentiment of dislike for libraries including lifetime parameters in their public APIs. Reasoning that I've seen includes the fact that it makes things more confusing for new Rust users (hence my own post here), but it may be just that. If this is true, why does Specs include so many lifetime parameters in its API? Is there some logical reason for it, or was it just laziness on the part of the author (no offense intended)?
My final question: speaking specifically to seasoned Rustaceans, what do I need to do to truly grok lifetime parameters? Is there a resource that provides an unabridged deep dive into how to use them and how to interpret what they mean when reading existing code? The Rust book provides a nice explanation of the simple case, but I'm looking for something more.
Thanks in advance!
r/Amethyst • u/Sibbo • Oct 29 '18
How to load entities from a file in amethyst?
Hey!
I'm currently struggling with the asset and prefab systems in Amethyst. I would like to load some entities from a .ron file.
The ideal case would be that the .ron file contains a list of component definitions, and each component is added as a new entity into the ecs.
Is there a simple or intended way to do this?
r/Amethyst • u/lowenware • Aug 10 '20
Amethyst and Terrain
Hello! What is the current state of terrain implementation in amethyst?
r/Amethyst • u/_Pho_ • Jul 14 '20
I want to contribute (especially with WASM) but I don't know how
Title. And sorry for the shitpost.
I want to contribute to Amethyst, particularly with WASM, but I don't have the expertise required to do so. I'm mostly a fullstack + mobile guy, with what I would say is a mid-level understanding of Rust and Amethyst. I want to contribute to the development of this framework, but I don't know where to begin. When the sentiment is "just get better learning Rust (for free) so you can contribute (for free)" it begins to be a daunting task. I'm two degrees removed. Contributing seems to require an advanced-level understanding of game engine architecture, systems architecture, networking, Rust, etc, and I just don't know where to begin.
Seriously, any help helping me help is appreciated.
r/Amethyst • u/pywang • Jun 30 '20
Creating a background Ui for my UiButtons
Hi all! I'm trying to make something like a bottom bar that's just a single color for my UiButtons. I created the UiButtons without a Ron file, so I'm just kinda lost on how to create something like a rectangle of a single solid color with UiImage.
PS: My UiButtons were created from UiButtonBuilder with dedicated images (pngs). Not entirely sure how to make it look like I'm hovering over them... like whiten them somehow. That's just extra; I really just need help creating this rectangle at the bottom of the screen. (Perhaps with more specific coordinates like middle of screen -200 per side).
Thanks!
Edit: I found this gem: https://github.com/amethyst/amethyst/pull/2311
It's a UI section that should be added to the book! Really good read.
r/Amethyst • u/khionu • Jun 29 '19
Bug Bounty for Intellij-Rust
Amethyst is sponsoring a bounty for an IntelliJ-Rust bug
If you know Kotlin and are comfortable taking on a bug in a Jetbrains plugin, please shoot me a message here, on Discord (Khionu#0047), or via email.
r/Amethyst • u/erlend_sh • Apr 20 '19