+2 votes

Hi, I would like to export an Array of a class that I create so I could change value in the scene view.

# BaseEnemy.gd

class AttackProperties:
    export (float) var range
    export (float) var degree
    export (float) var start_time
    export (float) var duration
    export (float) var damage

export (Array, AttackProperties) var list_attack_properties

To be honest, I would have love if that was possible but sadly it's not. So I wonder how I could do something equivalent to this.

Right now I'm focussing on creating a lot of enemies with the same pattern but different properties that make them "unique" in someway. Because I'm fairly new with Godot and never work with other engine so my only past experience is coding a Arkanoid clone with SFML 5 years ago. So I do have difficulties seeing through the "Godot eyes" on how I can implement features. I try to stay the more generic for my BaseEnemy so after that I can create inherited scene of my BaseEnemy scene to create more diverse enemies.

But I try to put every member that can influence gameplay of the scene as export members so it's easy to change enemies behavior without creating new code.

I'm working on a 2D Top Down Shooter. I'm also learning Godot while doing that so I'm still not fully aware of every tools I can use.

If you ask why an array : It's because if I want to create multiple type of attack, I could create something like melee attack and an other one is would be a range one, etc.
I try to implement case that don't exist right now but I will code later.

Thanks for your answer.

Image Legend:

  • Blue zone is drawing with AttackProperties.range and AttackProperties.degree
  • Red zone is drawing the field of view the enemy have (would be green if the player wasnt in it)
  • The rest is not important in the context

I put that here because there is no example of class being export and this is the nearest documentation to what I want to achieve

Edit : Image link wasn't working : https://imgur.com/tSgv7wI

in Engine by (14 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.