Replies: 3 comments 2 replies
-
Reflection (1)So rust doesn't have native reflection support, but bevy has its own library Note however that rust is a statically ahead-of-time compiled language, and has no built-in reflection support. So you'll have to go through bevy's library, and it's not as ergonomic to do that as in Javascript (or even Java). Reactive UI (2)Bevy is an ECS game engine. Every state goes into the ECS, either as component or resource. You use queries to access game state. End of story here really. On top of this, bevy's built-in UI library is to UI frameworks what slings are to modern armament (primitive to say the least). So you are likely to need to go through a 3rd party plugin for UI.
I've myself attempted to build an UI framework (or actually just a richtext library) that delegates state management to the ECS and I had to temporarily freeze development because of scope creep. Game object API handling (2) (3) (4)The main selling point of bevy is the ECS. All of bevy revolves around this. Bevy is not a rendering backend, but a game engine, and it requires control over your code flow. All bevy features such as rendering do depend and are extensively integrated with the ECS. This is fundamentally in contradiction with your game engine. You either need to drop your reactive system or use the ECS. You can use events as a temporary band-aid, but your code is a round object, and bevy a square peg. You'll be constantly fighting bevy if you try to port your code to bevy as-is and preserve the reactive aspect. If you want to "just" port your game engine to rust, you could go with a combination of Please check leptos, it's very similar to your reactive formulas system. The rest
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. I'm starting to get the picture as to how difficult this will be (I knew it would be hard, just not sure how hard). I still haven't decided if doing this is a good idea. (An alternative is to port my game to Unity, but I have zero Unity experience, and there are problems that are equally as daunting as the ones mentioned above.) You mentioned dialogues (BTW, I always use the spelling "dialog" to mean a modal UI element, and "dialogue" to mean a body of spoken text). I already have my own dialogue serialization format, which is based on JSON and works pretty well. This not only includes prompts and responses, but conditions as well - a lot of dialogue is conditional, especially quest dialogue which changes based on which stage the quest is in. Fortunately, dialogue conditions are pretty easy - there's only a small number of predicates (about a dozen), and these only need to be evaluated when displaying prompts, they don't need to be evaluated continuously. Quest stage predicates are a bigger problem, since quests can advance based on mutations in the game world. An example is a quest which advances when the character acquires a key quest item - essentially the predicate needs to watch the player's inventory for changes, and advance when the specified item is present. Other quest predicates can trigger based on NPC or environment states, which is tricky given that those entities aren't always loaded in memory. Slight digression for a moment: I have a long history of working with game scripting languages, I developed SAGA and SAGA 2 in 1992 (which are still supported in the SCUMM VM), I also worked with scripting languages at a number of game companies, including Edibles, which was the language we used while I was on the Sims 2 team. I'm also familiar with UnrealScript (circa 2002) and Bethesda's Papyrus / Creation Kit. What may be surprising, then, is that I am not very impressed with any of these languages - I have long felt that there must be a better way to script game behavior than writing imperative functions in languages which aren't far removed from Visual Basic. So part of what I set out to do in creating this game engine was to see if I could develop these ideas into something practical. The Solid.js / MobX style of reactivity seems to fit the bill - it means we can stop worrying about events and instead concentrate on what we really care about, which are intuitive notions of game state ("Am I hungry?" "Does this faction hate me?"). Turns out that using reactive formulas means that most traps / puzzles / mechanisms can be done in a single line of code. NPC AI is more complex since you have to deal with competing goal priorities, but the same principles can be applied. Given that, how does this apply to quests? Well, one could simply poll the quest transition predicate every frame, but if the game has a lot of active quests this is not very efficient. It's better if the trigger condition automatically subscribes to the data sources referenced by that condition, and only re-evaluates the condition when one or more of those data sources changes. This is not the way ECS does things, but that might not be important - because all of this logic is happening at a level above what ECS is doing. None of this stuff needs to execute every frame, and quests aren't game objects in the sense of being something that exists at some location within the game world - they are abstract global thingies. They influence what happens in the 3D scene, but are not part of it. There are a lot of objects which have similar status, such as experience points, tech trees, or entries in the player's spell book. Also, one can certainly bridge between the ECS and reactive worlds, similar to the way Redux selectors work - that is, if you can get some signal that an object has changed, and you have a comparator that checks to see if field X of the previous state equals field X of the new state, you can then trigger a callback - giving you fine-grained notifications of changes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For the past 3 years I have been working on a game engine based on three.js. Currently it's about 70K lines of TypeScript code for both the engine and the editor. Here's a screen shot to give you a sense of what it looks like:
So, I'm considering re-writing the engine in either Unity, Unreal or Bevy, as I am finding more and more that I am pushing the limits of what three.js can do. However, there are a ton of unknowns - I don't know if it's even possible to port the game to Bevy at this point.
Here's a list of some of the unknown issues:
Another example is editing of character color maps. Typically a parent archetype will specify how many color "slots" a given model supports, and then child archetypes will fill in those slots with specific colors. This allows, for example, to have a pack of wolves where each wolf has a slightly different fur color. The editor for the color choices field needs to know the color slot names, this is done via additional reflection metadata that contains the field name.
I don't know if Bevy's reflection framework supports anything like this.
I expect that the UI data-binding paradigms in something like Bevy are very different from Solid, and would require a complete redesign of the editor.
In fact, my original motivation in writing my own engine (instead of using Unity) was to research the feasibility of this approach to scripting. There's nothing like this in the Bevy world so far as I know.
Asynchronous logic. A lot of the game engine's logic only happens rarely, rather than requiring an update every frame. Things like pathfinding, navigation mesh construction, terrain generation and so on all happen in between renders and typically take more than a single frame worth of time to complete. Also, the engine loads scenery data in the background as the player moves around the map, allowing worlds of nearly unlimited size, but the load operations are i/o bound and there is significant post-processing required when an scenery asset is loaded. The tutorials on Bevy schedules don't mention this kind of scheduling.
Instancing. The engine makes heavy use of WebGL instancing, so for example in the screenshot there are 16 chairs but only one mesh instance loaded. How this works in Bevy is to be determined.
Outlines. The game has a deliberate "Art Nouveau" visual style (more apparent in the HUD overlays than in the 3D scene) but you can see for example that objects have black outlines. This is done using the inflated-normal technique, so each model instance is rendered twice, one with front-facing polys and once with back-facing. So the question is how this sort of thing would work in a Bevy environment.
Dynamic color palettes. The game has hundreds of characters, but only a few dozen unique character models. Characters have a special GL shader that allows materials to be recolored on a per-instance basis, using the color slots mentioned earlier.
Editor UI. The editor runs in a browser and has it's own UI widget set. One possible approach for porting the engine would be to keep the editor as a web app written in TypeScript, and then use something like Tauri to allow the Rust game engine to export a service API which the editor could call. (WASM is also an option, but I don't want to be constrained by WASM limitations).
Re-doing the editor entirely in Bevy UI would be a huge task, especially given that game UI widgets are often designed quite differently than editor widgets and have different needs for things like layout, scrolling, copy and paste, keyboard shortcuts and so on.
To sum up, I'm not sure that porting the engine is a good idea, but I'm curious to find out more.
Beta Was this translation helpful? Give feedback.
All reactions