#referencing gltf files from ron

9 messages · Page 1 of 1 (latest)

hollow parcel
#

Hi,

I'm making a tower defense game, each tower has stats (damage, range, etc) held in a ron file, each tower also has its own glb file. I'm unsure on the best way to reference the glb files from the ron config file.

#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, Asset, TypePath)]
struct TowerDetails {
    name: String,
    cost: u32,
    damage: u32,
    range: u32,
    attack_speed: u32,
}

I've got this as a base, but if I add mesh: Handle<Gltf> to it it won't work as Handle<Gltf> doesn't implement deserialise. Any ideas what I should be doing instead? Any example of this?

Thanks in advance.

halcyon timber
#

Have you tried with Handle<Scene>?

hollow parcel
#

That has the same issue. I'm thinking just String for now which points to the file path, but I feel like that's going to cause more issues

#

The error (for Gltf) is:

rustc: the trait bound `bevy::prelude::Handle<bevy::prelude::Gltf>: Deserialize<'_>` is not satisfied
for local types consider adding `#[derive(serde::Deserialize)]` to your `bevy::prelude::Handle<bevy::prelude::Gltf>` type
for types from other crates check whether the crate offers a `serde` feature flag
halcyon timber
#

But later look into making it into a Asset

hollow parcel
#

It's already an Asset 😦

slate compass
#

I wonder if you'd end up having to wrap Handle<Scene> with your own type to make this work 🤔 strings might be simplest in the meantime

halcyon timber
#

i skipped some of the derives, sorry, but what i wanted to get to was, you could make an AssetLoader, with Asset being your TowerDetails and registering a labeled asset for a Scene, so that you can do asset_server.load("frost.tower.ron#Tower");, or whatever you want to call it