Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve User defined Classes #10094

Open
mrjustaguy opened this issue Jul 2, 2024 · 1 comment
Open

Improve User defined Classes #10094

mrjustaguy opened this issue Jul 2, 2024 · 1 comment

Comments

@mrjustaguy
Copy link

Describe the project you are working on

FPS

Describe the problem or limitation you are having in your project

User defined Classes don't act anything like Built-in Classes (like Node3D, CharacterBody3D etc.)

User Classes add a regular old Script which has the downside of erasing any modified Class variable data when changing to a script that extends the User Class

Example:
User Class - Vehicle has a variable Speed
Vehicle Controller is a Script that extends Vehicle
Assigning Vehicle Controller Script to the Vehicle resets Speed

This basically breaks any logic where you have to switch controllers around dynamically (like No controller - no Script, AI controller - AI script, Player controller - Player script)

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a Class_Script that would hold the Script of any User Classes in essence making User Classes act like Built in Classes from the User's perspective

This would mean:

  1. In the Editor User Classes would no longer have a Script defined, just a Class, albeit they'd have a link to the user script defining the class instead of built-in
  2. Setting Scripts wouldn't Reset all User Class Variables

This resolves the issue in the example above as Class Variables are shielded from resetting when setting a script
In the example above that would mean that much like when you set a script extending Node3D you don't lose your position, you wouldn't lose the vehicle's Speed

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Simply apply the Built-in Class logic to User Defined Classes, with the one difference of having a Variable for User defined Classes that would store the Class Script.

If this enhancement will not be used often, can it be worked around with a few lines of script?

You cannot fully workaround User Classes not behaving like Built-in Classes

Is there a reason why this should be core and not an add-on in the asset library?

This is a issue with Core

@KoBeWi
Copy link
Member

KoBeWi commented Jul 2, 2024

Similar to #7905, which has an implementation pull request.

the downside of erasing any modified Class variable data when changing to a script that extends the User Class

That's a bug.

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

No branches or pull requests

3 participants