Ai is taking over coding lol

I just asked copilot AI to write a script for swinging a sword, and this is what it came up with. I’m seriously impressed.

Certainly! Let’s create a simple sword-swinging mechanism in GDScript. I’ll guide you through the process step by step.

Create a Sword Scene:
First, create a new scene for your sword. Add a Node2D or Area2D as the root node.
Attach a CollisionShape2D to the sword. Adjust its shape to match the sword’s hitbox during the swing animation1.
You can also add a sprite to represent the sword visually.
Player Script:
In your player script, handle input (e.g., a key press) to trigger the sword swing.
When the input is detected, emit a signal from the player to the sword scene.
Sword Script:
In the sword scene, create a script.
Listen for the signal from the player (e.g., “swing_sword”).
When the signal is received, play an animation that simulates the sword swing.
At the end of the animation, emit another signal (e.g., “sword_hit”) to indicate that the sword has hit something.
Damage Calculation:
In your enemy or target script, listen for the “sword_hit” signal.
When the signal is received, apply damage to the enemy or target.
Here’s a simplified example of how you might handle the sword swing animation in GDScript:


extends Node2D

var sword: Node2D
var swinging: bool = false

func _ready():
    sword = $Sword  # Reference to your sword node

func _process(delta: float):
    if Input.is_action_just_pressed("swing_sword") and not swinging:
        swinging = true
        $AnimationPlayer.play("sword_swing")  # Play the sword swing animation

func _on_Sword_animation_finished():
    # Called when the sword swing animation ends
    swinging = false
    emit_signal("sword_hit")  # Signal that the sword has hit something

Remember to replace “swing_sword” with the actual input action you want to use for sword swinging. Adjust the animation names and signals according to your project setup.

Feel free to customize this code to fit your game’s mechanics and animations. Happy sword swinging! :dagger::boom:

1 Like

Well probably the first thing you are going to have to correct on this code is the fact that its going to send a “sword_hit” signal even when the sword hasn’t hit anything.

3 Likes

This is probably something that was inevitable with the advancement of AI these days. People with no coding knowledge will probably be able to make High quality games some day, And it’s all thanks to AI

yeah, i noticed that. still impressive though! its probably assuming you already have a way to check collisions, and expecting you to replace it.

Not for a very long time yet.

1 Like

From my experience, it’s been better to just learn how to write the code myself than to rely on Generative AI. It keeps messing things up that I have to bugfix and end up spending just as much time or longer working on the code. Common issue is that it uses Godot 3 compatible code while trying to help you with Godot 4.

I have explicitly pointed out that it should be using @export instead of export to which it thanked me for pointing that out and IMMEDIATELY forgot it and gave me the exact same block of code.

It might take a while before it’s good enough to replace a human.

4 Likes

I believe that AI won’t replace humans completely, but will be an important tool to code games more efficiently.

There is a moment where the actual difficult part regarding gamedev is making enjoyable games, not just games that work and have 0 bugs.

You need humans to test the game and decide what needs to be changed in order to make things funny! Then, AI will make it easier to write the specific code.

That’s my take for almost every scenario when people talk about robots replacing us.

But I might be wrong and maybe we all end up living like those guys in the Wall•e films! xD

2 Likes

Well I honestly wonder if the coming AI revolution is as close as some think it is. Remember when Tesla said that their self-driving AI is just a year or two away?

Of course looking at examples like this you will be impressed, but if the last 10 years of witnessing this generation of AI succedding and failing at different things taught me anything, it’s that getting to 99.9% is easy, it’s the chasing remaining 9s that is extremely hard, and at some point just throwing more data or compute at the thing doesn’t work anymore because you already thrown all data at it that our civilization has so far produced.

And in the programming you have to be 100% correct, or it wont work. Or if you encounter a bug, you have to have an actual capacity to fix it without introducing new ones.

1 Like

Wow. This taught me more about Godot game programming than a dozen attempts to read the docs and numerous tutorials.

Lets embed GitHub - stitionai/devika: Devika is an Agentic AI Software Engineer that can understand high-level human instructions, break them down into steps, research relevant information, and write code to achieve the given objective. Devika aims to be a competitive open-source alternative to Devin by Cognition AI. into Godot so that we won’t have to wait two years. :smiley:

Right. Godot should export all prompts, responses and corrections, so that next versions of LLM can be trained not to make these mistakes. This probably can be called “fine-tuning corpus”, although I need some expert help to understand what is the best format the projects can export their collective knowledge.

I use AI every single day. But I would never ask it to code anything directly. I might ask it about approach, or for an example of something simple, but that reflects my ‘beginner’ status for coding. Sometimes I might say “how do I do this” but usually the answer gives me the clue of what to search for in docs. I also have the docs open every single day.

A recent example was affine_inverse(), found on AI, learned about in the docs, experimented with and eventually added it to my game.

It is a fabulous tool. But it is just a large language model and it does hullacinate. It often completely makes up functions.

“Sorry, you are correct, that function does not exist in GDScript.”

I love AI, but get real, it is not taking over the world, is not replacing humans, and is not intelligent in the ‘conscious intelligent being’ way. It is a very clever tool but it is already peaking in it’s abilities.

PS I hope the get their arses sued for stealing everyones work without credit!

2 Likes

Well sadly the tutorial part of this output is the worst offender for invalid information. AI is really good at sounding correct, though it’s not. If you followed along you’d notice how much doesn’t work.

  1. The first line is incorrect, it must be an Area2D for collisions without stopping

Add a Node2D or Area2D as the root node.

  1. There is no signal emitting from the player to the sword, it is using the input as an if statement

When the input is detected, emit a signal from the player to the sword scene.

  1. again, no signal from player to sword

Listen for the signal from the player (e.g., “swing_sword”).

  1. Good time to mention the AI does not cover adding an AnimationPlayer or use collision at all

At the end of the animation, emit another signal (e.g., “sword_hit”) to indicate that the sword has hit something.

  1. This is incredibly difficult to actually do and would couple enemies to swords in a backwards way that defies all convention.

In your enemy or target script, listen for the “sword_hit” signal

bonus: var sword is never used and var swinging is unnecessary as animations do not restart on play


I’ve seen AI be a real danger for forums like this. The roblox devforum uses discourse as well and we’ve seen AI responses disrupt good help and send many stray.

1 Like

The only way to get AI smarted is to teach them.

So how would a correct code look like?

I think that time is sooner than you think. Image AI only 2 years ago couldn’t get hands right, now it has no issue with them, unless the site you are using to generate AI images is running some outdated model. The text seems to be the current pain point (with AI generating incomprehensible glyphs where text should be), but it starts to overcome that as well.

In the text gen AI (the one you are going to use for code if you use AI at all) the improvements are much less visible, but the progress is still being done.

Lastly, Copilot isn’t the best AI model for coding either. Claude 3.5 Sonnet seems to be the best one right now (unless my info is outdated) but even Meta’s Llama models (that can be used locally) run circles around Copilot/ChatGPT 3.5.

Agreed, sometimes you know WHAT you want to do, but not HOW to do it and getting even broken code that you need to fix but which mostly does what you want it to do is better than having no code at all. The AI is also less likely to accuse you of you wanting someone to make homework for you (thing I encountered multiple times when I was asking around noob questions as I was trying to learn programming on my own in the dark ages of 2004).

1 Like

Just be careful you don’t fall into this trap: it isn’t assuming anything. it doesn’t know things, it doesn’t deal with facts or logic. it deals with statistical probability of words and characters.

1 Like