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);
}
}
}