The value of AI for coding and learning?

I’ve heard hundreds of opinions about the use of AI, both for and against (including some I outright disregard, like an actual software engineer who swore that his job would be obsolete in years)

I think the balanced view is that it can be used as a tool but doesn’t replace actual knowledge.

Case in point : last night I was using ChatGPT to script some stuff. I could do by hand but I wanted to see what the AI would come up with.

I encountered a point in which I added a new script and it broke my movement. Couldn’t figure out why. I asked Google and Chat, no conclusive answers. I messed around and fixed it (can’t remember how)

Then I added a new shooting script which didn’t send my projectiles flying to the right, even though it was in the code. Chat didn’t provide any answers.

(these are the highlights, lots of minor stuff I Googled)

I’m not sure how much of this is AI, and how much of this is just actual normal gamedev stuff (it should work but it doesn’t) so I thought I would ask to learn and discuss.

Code for reference :


using UnityEngine;

public class BulletController : MonoBehaviour
{
    public float speed = 10f; // Speed of the bullet
    public int damage = 1; // Damage inflicted on enemies

    Rigidbody2D rb; // Reference to the Rigidbody2D component

    void Start()
    {
        rb = GetComponent<Rigidbody2D>(); // Get the Rigidbody2D component of the bullet
        rb.velocity = transform.right * speed; // Set initial velocity to move the bullet horizontally to the right
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        // Check if the bullet collided with an enemy
        EnemyController enemy = other.GetComponent<EnemyController>();
        if (enemy != null)
        {
            enemy.TakeDamage(damage); // Call the TakeDamage method on the enemy
            Destroy(gameObject); // Destroy the bullet on collision with an enemy
        }
    }

    void Update()
    {
        // Destroy the bullet if it goes out of the screen (optional)
        if (transform.position.x > 10f || transform.position.x < -10f)
        {
            Destroy(gameObject);
        }
    }
}

What does happen? How are the projectiles instantiated? Is this script attached to the projectiles?

A single script out of the context of your project is not enough information. More details would be helpful.

For your first topic, I am of the opinion that one should learn coding first and use AI as a tool after they have a good grasp of the basic concepts. From what I have seen others post, AI gets you close, but does not create working, robust code. I have not tried it myself. I am learning game dev for a hobby and taking short cuts seems counter productive to learning. Just my opinion😊.

1 Like

The projectiles appear but don’t have any behavior. The script is attached.

I decided to not continue with this at the moment as I have a lot of other things to do.

I more or less agree with you.

I am with edc, you should not use AI to code your game, the code it produces is mediocre at best and optimised. That being said you can use it as a helping hand but you should understand what the code is doing, and asking it questions rather than having it spit out code. for example if you are a beginner and don’t know the diffrence and when to use say a list, array or dictionary then AI is actually pretty decent at giving examples and explaining stuff, but when it comes to choosing the right one most of the time it never chooses the best way to do things.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms