Hello, thanks for any and all help.

I'm trying to understand why something isn't working, not because I can't solve it in a different way, but rather because If I don't figure this out it can cause blockades down the line, and I also want to grow my knowledge of the engine.

I have these two scripts...

Bullet has an EXPORTED Bullet.speedDefault and a Bullet.speed that gets initialize by the default. This Bullet.speed is what's actually used for calculations. It also has a function to "fire" itself, but it might not be relevant for this problem...

Gun preloads the Bullet PackedScene and then uses it when a shoot functions runs. Inside this shoot() function, a Bullet is instanced, and then its Bullet.speed value is called to help set its impulse...

HERE'S WHAT I DON'T GET No matter to what I set the speedDefault of the bullet scene in the EDITOR, it will always just use the hard coded values set on the script (in this example 1000). And I don't know why this could be happening?

Why isn't my bullet instance using the speedDefault value I set on the editor scene? Is it because of preload in any way? Is it because instancing? How do I get this to work with the exported speedDefault? I would prefer to use exported than hard coding anything...

PS: I made sure everything was saved and tried to set the Bullet.speed in the _ready() function, but it still ignores the editor set value.

I take it that this "EDK-Games" is also you? -snip- topic deleted.

Email certainly matches. If it's your duplicate account I'll remove it.

@Megalomaniak said: I take it that this "EDK-Games" is also you? https://godotforums.org/discussion/27034/please-help-me-understand-preload-and-why-this-example-inside-doesnt-work

Email certainly matches. If it's your duplicate account I'll remove it.

Yes, my apologies for that. In my email I wrote "hotmai" without the L, by accident and I thought my post wouldn't even go through. Then I couldn't figure out how to change the email within the account OR even delete the account. I would have liked to.

Well, so long as you were able to log in you could have just edited account and changed the email but it is no big deal. It's just that we have a rule against having multiple accounts so I'll delete the duplicate post and account.

Let me know(PM me or create a topic for request in Forum Chat category) if you should want an account name change after as well. I'll not drag this discussion any further off-topic. :)

One way to check if it's the preload is to not use it and see if you get the same results. Also, if it's a scene, when was the scene saved before or after the editor was changed. These would just be some experiments. I don't know the answer myself.

@fire7side said: One way to check if it's the preload is to not use it and see if you get the same results. Also, if it's a scene, when was the scene saved before or after the editor was changed. These would just be some experiments. I don't know the answer myself.

Thanks for the response!

I experimented a bit and it looks to me like adding the speedDefault to speed when I initialize DOES NOT take into account the exported value in the editor.

So, the RED arrow in the image, is redundant, as it only takes into account the hard-coded value in the script, and not in-editor. The GREEN arrow in the image, actually passes in the value from the export in editor.

I would prefer I didn't have to set the value twice, but this seems to work. What surprised me the most is that, even when I put the value on the _ready() function, it would still NOT use the editor values. That's why I had to set the value upon "firing."

PS: I also changed the "fire" function to pass in the speed directly from the Bullet, because it made more sense for this particular case.

You should either comment out or remove what you have on line 7 there. I mean the assignment. If you are overriding it later anyways. Just make it var speed : float then copy and paste line 13 into the _ready() function instead.

You might also want to explore the concept of setters and getters(note that setters and getters will change in version 4). https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html#setters-getters

a year later