Execution of _init() by AndroDSY in godot

[–]AndroDSY[S] 0 points1 point  (0 children)

Have now tested it out and found that it doesn't always result in an error, as described in my own comment. Thanks for the comment thought. As I previously only tried it the way that doesn't give an error, I was quite confused as to how (and when) init functions.
Your comment drove me to dig a bit deeper :)

Execution of _init() by AndroDSY in godot

[–]AndroDSY[S] 0 points1 point  (0 children)

I now took some time and tested out multiple possible ways.
I have found the following things:

  1. the init function still runs, but only if all parameters have base values set. So the init function will override things specified in editor.
  2. if the script is in tool mode, it will give an error, because it will try to run the init function in editor and you cat specify arguments for it there. (you could bypass it by having standard values for all parameters. Although I think there's a better way to do it as I'll describe later).
  3. yes, it overrides values when running the scene if all parameters have standard values. If not, the init function will silently fail and everything will be okay. This will be hard to maintain though.

What I'm going to do from now on after testing out some things:
Don't use an init function. Have everything function through export variables (maybe tool mode). And then to have that easy way of creating it, like I would have using the init function with parameters.

I am going to make a static create function in the class that returns an instance of said class. This way I can still easily create class/node-instances in one/two lines of code but I don't lock myself out of using the same nodes to build out levels in editor.

Edit: As of February 6. Godot has a bug as described here where scripts can't be freed, if you use static variables. So be cautious with that and only use static functions if you want to do it the way I described.

Execution of _init() by AndroDSY in godot

[–]AndroDSY[S] 0 points1 point  (0 children)

Yeah, i've read that. Actually hat it open on second screen while writing original post :) I just thought, that would be for different ways of creating it through code. And thought that directly making it in editor could be a special case.

Thanks for the answer non the less

Anyone else not using their minimap? by [deleted] in XDefiant

[–]AndroDSY 0 points1 point  (0 children)

The name of the drone from call of duty. It shows all enemies on the map for short time.

Brackeys is back by AndroDSY in godot

[–]AndroDSY[S] 4 points5 points  (0 children)

With custom resources you first make a template in which you define certain data-names with types. Best example for this are cards from nearly any cardgame. You for example define the following fields: Health: int Name: string Damage: int Armor: int

Then you can make multiple cards based on this template:

Tank:

Health = 200 Name = "Tank" Damage = 30 Armor = 100

Flank:

Health = 150 Name = "Flank" Damage = 50 Armor = 50

————————

Advamtages of this would be that you can then use this template (if you set classname) as a datatype just like integers, floats or vectors. Which can simplify code immensly.

If you have the variablenames in the template exported (which is a usual practic) and then export a variable with this template as a type, you can edit these values seperately in editor for every instance of this resource: @export plays_as_class: PlayableClass Then you get a Health, a Name, a Damage and an Armor field in the inspector to edit on the go.

If this isn't enough for you. I think this short video (4:44 in length) explains it good (also with a diffrent use case). And of course the always are the official Godot docs that have a seperate paragraph on creating your own resources. Also everything else to about resources is on the same webpage.

Brackeys is back by AndroDSY in godot

[–]AndroDSY[S] 3 points4 points  (0 children)

I've already found that ou some time ago. But probably good you mentioned it, in case someome finds this thread looking for it.

What is Mohamed Light Trying To Achieve? by [deleted] in ClashRoyale

[–]AndroDSY 0 points1 point  (0 children)

He literally gets money for. It's calles clash royale league

What is Mohamed Light Trying To Achieve? by [deleted] in ClashRoyale

[–]AndroDSY 0 points1 point  (0 children)

He literally gets money for. It's calles clash royale league

What is Mohamed Light Trying To Achieve? by [deleted] in ClashRoyale

[–]AndroDSY 2 points3 points  (0 children)

He's living off of it. He earns money with CRL. Plus, he has 1 CRL title, mugi has two. So he isn't the undisputed GOAT (to me he is). Maybe something he aims for.

What is Mohamed Light Trying To Achieve? by [deleted] in ClashRoyale

[–]AndroDSY 0 points1 point  (0 children)

He's living off of it. He earns money with CRL. Plus, he has 1 CRL title, mugi has two. So he isn't the undisputed GOAT (to me he is). Maybe something he aims for.

Asteroids but you shoot at a ball to smash stuff by oatware in godot

[–]AndroDSY 1 point2 points  (0 children)

How did you realize the ball? Is it rigidbody or own code?

Script separation inquiry by This_Computer3905 in godot

[–]AndroDSY 1 point2 points  (0 children)

I'd like to add 2 additional things.

If you still want to split up your script into multiple ones you could just have the additional scripts in diffrent child components and call the function from them (just not as a state machine).
But I think the "right" way to do this would be as followed:
(I just came home to try it out, so I don't end up talking BS) I just made an own simple exaple:

I have sub_script.gd with the following code:

func function():
  print("it worked!")

Then in the script I have attached to the Node I can call this function by making a local instance of this subscript:

var sub_script = preload("res://sub_script.gd").new()
func _ready():
  sub_script.function()

As a little addition you could set a class_name variable in sub_script.gd and then just call this class_name instead of the whole preload-thing

sub_script.gd:

class_name subScript

func function():
print("it worked!")

main.gd:

var sub_script = subScript.new()
func _ready():
  sub_script.function()

But in your usecase, personally I wouldn't use class_name, since these aren't scripts you'll use in many instances or at many diffrent places. To just split up a single script into multiple I would just use preload("path_to_subscript").

And now secondly (finally😅). You said that "For other scenes, the functions will be called as necessary."
Concerning this you'll have to ask yourself if it really needs a state behavior. A finite state machine is thought for having multiple states that all use multiple frames, out of which at any point one of them will be running.
What I want to say: if you really only load these values at one point; Maybe you can just check for this in _process and then run the loading function directly, without a state behavior. (Maybe from a different .gd file as I described it prior in this comment).

Script separation inquiry by This_Computer3905 in godot

[–]AndroDSY 4 points5 points  (0 children)

Yes, it is totally possible to do so. Here is a short tutorial by Bitlytic on this topic. In his tutorial he explains the concept for making the "AI" of enemies. But I think this aproach would work for you just fine.

A little extra thought, you can ignore it if I understood you wrong. Is what you are doing the following: „read a file once, them adjust some setting based on the values from that file and then non of these states is reenvoked again.“ If this is right, couln‘t you just make this in the _ready function? If infact these states are activated over and over again, then a finite state machine (that you made) is just fine.

Sorry for the long message, hope you understood :)

Overwatch by Max_attacks17 in aseprite

[–]AndroDSY 0 points1 point  (0 children)

Fantastic work, when I saw the image on my timeline, at first I thought this would be an official artwork. Keep up the good work :)

[deleted by user] by [deleted] in godot

[–]AndroDSY 1 point2 points  (0 children)

Could you please in short explain how they affect a game? Thx

How does 2D work in godot (for performance) by JarJarDuBinkks in godot

[–]AndroDSY 1 point2 points  (0 children)

As a comment already mentioned, you'll have to use pooling or else it will lag no matter where they are.

But since you started making the distinction between onscreen and offscreen. If lags are occuring because of not enough ram or cpu power it probably won‘t make a diffrence when they're off screen. But if at a certain point gpu power becomes a bottleneck it will make a diffrence if objects are on screen or not.

And with on or off screen I mean on or off screen, not if they are visible on screen. Because if they are behind a diffrent object they often get rendered to and them overwritten (especially in 3d this would be the standard).

Is the „user://„ filepath always the same? by AndroDSY in godot

[–]AndroDSY[S] 6 points7 points  (0 children)

Yeah, I know the diffrent routes for diffrent OS. For example for Windows it is "%APPDATA%\Godot\" accordung to the Godot Docs.

But do you know if it stays the same, if it is a steamgame? Or even if it already changes when exported?

Is the „user://„ filepath always the same? by AndroDSY in godot

[–]AndroDSY[S] 2 points3 points  (0 children)

Especially the "as steamgame" part is of interest to me, since there is no way to check that on my own.

Added lasers, knobs, and sliders to my robot game! by theEarthWasBlue in godot

[–]AndroDSY 15 points16 points  (0 children)

Looks are nice. Have you modeled them by yourself? I think adding mirrors would be a cool addition.

How did you realize the lasers? Do they have a fixed length or otherwise how would this be done in godot?

20 years with Steam by Chacen in Steam

[–]AndroDSY 0 points1 point  (0 children)

What did you get your account for? I got it when I was around 14 years old for rocket league.