One question. You say "as always this project is available on github" but I don't see any links to github in the description or comments. Can you please add one for folks who may not know it already?
@AndrewWooldridge5 жыл бұрын
This is , in fact really super useful! I'm glad you created this tutorial. It was exactly what I was looking for.
@ClassyWolf3 жыл бұрын
Best tutorial for classes out there.
@ac11dc1105 жыл бұрын
HOLLY WOW!?? I WAS JUST SEARCHING FOR THIS, 5MIN YOU UPLOAD
@annief1515 жыл бұрын
Hello GDquest. Thank you very much for taking the time to make these videos. If I may ask, could you possibly make a video on how to spawn things without the need of input from the user? May sound silly, but so far, all tutorials I've come across, the add_child call is always reliant on some sort of key press or mouse press. Thank you! Keep up the great work!
@pigdev5 жыл бұрын
May I suggest some content? Maybe they can help. Using the Factory Method pattern to make spawners kzbin.info/www/bejne/pJO1c4iJjbqMp7c The spawners classes from my game github.com/pigdevstudio/moon-cheeser/tree/master/source/objects/spawners An older implementation, turn on the captions! kzbin.info/www/bejne/joSpdY2bnslphac
@willnationsdev5 жыл бұрын
I believe answering your question requires more information. Scripting means plugging behavior into an existing system, so Godot has several callbacks it provides users to add logic. These are the "notification" methods which include the input functions, but also things like _init(), _enter_tree(), _exit_tree(), _ready(), _process(delta), etc. If you specify when it is you would like to spawn objects, we can provide an example of how that would work. In large part, you will always be doing something like this... var node = Node.new() # create & assign node.name = "Hello" # initialize properties add_child(node) # add to SceneTree ...or, for a scene... var scene = load("res://my_scene.tscn") add_child(scene.instance()) ...or, for a script... var script = load("res://my_script.gd") add_child(script.new())
@annief1515 жыл бұрын
I will check out the videos soon.
@annief1515 жыл бұрын
@@willnationsdev I am happy to give context, as I understand my question may have been a bit vague. My game I am currently using is a brick breaking type game. It contains 3 Nodes(Paddles, Walls, Bricks), and one node that was turned into a scene (Ball). So far the Paddle and the Ball are scripted. First the paddle. (I think you will see what I am trying to do, when you miss the ball with the paddle, and it falls off screen it is queued_free, I would like it to automatcally spawn with a vector) extends KinematicBody2D class_name Paddle var Ball = load("res://Mini Scene/Ball.tscn") func _ready(): set_physics_process(true) func _physics_process(delta): var y = position.y var mouse_x = get_viewport().get_mouse_position().x set_position(Vector2(mouse_x, y)) #func _Ball(): (This is one style I tried) # if Ball == queue_free(): # var Ball1 = Ball.instance() # add_child("Ball").set_position(position-Vector2(320, 352)) # print("Ball has been created") func _notification(Ball): if Ball != queue_free(): var new_ball = Ball.instance() new_ball.position = Vector2(0, 16) get_parent().add_child(Ball) And now here is the Ball script. extends RigidBody2D class_name Ball const SpeedUp = 10 const MaxSpeed = 300 func _ready(): set_physics_process(true) set_process_input(true) func _physics_process(delta): var bodies = get_colliding_bodies() for body in bodies: if body.is_in_group("Bricks"): body.queue_free() if body.get_name() == "Paddle": var speed = get_linear_velocity().length() var direction = position - body.get_node("Anchor").get_global_position() var velocity = direction.normalized()*min(speed+SpeedUp, MaxSpeed) set_linear_velocity(velocity) if position.y > get_viewport_rect().end.y: queue_free() print("Ball died")
@arturkarlov30005 жыл бұрын
what is ._shoot() (with the leading dot before the underscore)? I don't think I have seen this before.
@Gdquest5 жыл бұрын
The dot means "call this method on the parent class"
@arturkarlov30005 жыл бұрын
@@Gdquest Cool, thank you! is this a new thing or was it always there?
@IndividualFreedomNet3 жыл бұрын
How do you inherit from an abstract base class like BaseButton and make it a concrete class? (I want to make my own button type which inherits BaseButton's features, but implement all the visual stuff myself as it's different from both the standard Button and TextureButton.)
@androidgameplays4every135 жыл бұрын
I like your voice and pace.
@serge42645 жыл бұрын
Got a question That's fine buuut how to implement a non-inherited class? And furthermore include it to my script?
@SoftBreadSoft5 жыл бұрын
AI A script not attached to any node wont be inherited. Then to instance the class const name = load("res://thescript.gd") var theinstance = name.new() Then you can access the variables and methods in the class. E.g. theinstance.somemethod()
@Ach4765 жыл бұрын
What is the benefit of referencing the class name to determine the node type vs using the node Group feature?
@igomesigomes4 жыл бұрын
You can not rely on groups to be sure that every object it contains is of the same type.
@josesena43145 жыл бұрын
Nice tutorial. Is there any actual advantage of using this other than type check?
@pigdev5 жыл бұрын
this is type checking :D This feature allows you to make type checking easily. Before that you had to add something like const ClassName = preload("res://path/to/script.gd") and then check
@josesena43145 жыл бұрын
@@pigdev I know. I just asked if there's any other advantage other than this. Thanks for answering anyway :D
@pigdev5 жыл бұрын
@@josesena4314 Ohh, my bad. The major advantage is also getting autocompletion for your custom classes as well.
@pigdev5 жыл бұрын
@@josesena4314 And of couse, casting etc...
@Kokounet5 жыл бұрын
Didn't your way of talking changed? it seems different from previous videos ! I really like your work by the way !
@tralavala98085 жыл бұрын
Atm there are 3 ppl that make tutorials here ;p
@Kokounet5 жыл бұрын
@@tralavala9808 oh okay I didn't know! Thanks
@Marvin-t3e5 жыл бұрын
It can be confusion if you are using rudimentary assignments. Nice video anyway 😀
@yapayzeka4 жыл бұрын
hard to understand. video is like a show off that presenter knows things.