Game Development tutorials
Game Development  journey
Beginner "how to" tutorials , programming, software usage,  artwork, news  and more
For TIPS and SHORT TUTORIALS
 FOLLOW 
100+

How to override a function in GDScript

Posted by Vix Mark on January 14No Comments
function override INFOGRAPHIC

Let's say you have a base Class with a function which you'd like to extend or change in the Object that inherits from the base Class. To get it done we need to declare (override) that function using the same name again in the Object's GDScript file and write the needed code, so when it's called those lines of code get executed instead of the ones written in the base Class.

If you still have to use the instructions contained by the overridden function with the newly written piece of code - call it using the dot sign. Here's a simple example:

func change_state(new_state):
	if new_state > 0:
		.change_state(new_state)
Share this
Pin it
Conversation
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
©2026 GamaDevFcups - how to make Indie Games.

Game Development: Godot Engine, Krita, Blender, programming, tutorials

GameDevFcups

Desidned and built by VixStudio
 | 
VixMark@protonmail.com
pointer-down
0
Would love your thoughts, please comment.x
()
x