How do i make an AI Enemy shoot at the player?

Bentley

Member
Also do you know what this means in the photo?
I believe that when it reads this line:
Code:
point_direction(x, y, WinterShipFighter.x, WinterShipFighter.y)
The instance doesn't exist yet. In other words, it's checking for an instance that is not in the room, and therefore gives you an error. It's also possible that you don't have an object named that (but I don't think that's what's going on in your case).

I highly recommend prefixing your resources. obj_WinterShipFighter is the way to go. Do the same for your sprites.
 
P

Player12Coconut

Guest
I believe that when it reads this line:
Code:
point_direction(x, y, WinterShipFighter.x, WinterShipFighter.y)
The instance doesn't exist yet. In other words, it's checking for an instance that is not in the room, and therefore gives you an error. It's also possible that you don't have an object named that (but I don't think that's what's going on in your case).

I highly recommend prefixing your resources. obj_WinterShipFighter is the way to go. Do the same for your sprites.
but i already changed it to obj_WinterShipFighter
and changed all of the codes that are WinterShipFighter to obj_WinterShipFighter
 

Bentley

Member
but i already changed it to obj_WinterShipFighter
and changed all of the codes that are WinterShipFighter to obj_WinterShipFighter
Then that is why you're getting that error. The code is checking for "WinterShipFighter" which doesn't exist. Make it check for "obj_WinterShipFighter". Switch the names in that line of code.
 
P

Player12Coconut

Guest
Then that is why you're getting that error. The code is checking for "WinterShipFighter" which doesn't exist. Make it check for "obj_WinterShipFighter". Switch the names in that line of code.
But I already did. It’s also highlighted as an Object. The code in that line is
direction = point_direction(x, y, obj_WinterShipFighter.x, obj_WinterShipFighter.y);
 
Last edited by a moderator:
P

Player12Coconut

Guest
Then that is why you're getting that error. The code is checking for "WinterShipFighter" which doesn't exist. Make it check for "obj_WinterShipFighter". Switch the names in that line of code.
It also happens when WinterShipFighter hits something else that has a collusion with it and in it has the code instance destroy. I don't think it has anything to do with the Empire gunners or the lasers. The error happened whenever the WinterShipFighter goes over Destroy Instance.
 
P

Player12Coconut

Guest
Then that is why you're getting that error. The code is checking for "WinterShipFighter" which doesn't exist. Make it check for "obj_WinterShipFighter". Switch the names in that line of code.
I found out what was the problem. I made a rock object and WinterShipFighter has a collusion event with the rock and the collusion has a code in it that has the instance destroy code, and every time i hit the rock the Error with come up. The game has a problem finding WinterShipFighter because it was destroyed by hitting the rock, but i don't know how to make it so it'll stop trying to find it once it's destroyed.
 
Last edited by a moderator:
P

Player12Coconut

Guest
Then that is why you're getting that error. The code is checking for "WinterShipFighter" which doesn't exist. Make it check for "obj_WinterShipFighter". Switch the names in that line of code.
Nevermind, i think that’s about it that I need help for now, Tysm for helping!
 
S

Slyferro

Guest
Is there a way to make the enemy shoot whatever direction it is facing rather than at the player directly?
 
O

Obj_Neil

Guest
I want to commend Bentley for his patients.

I don't see anything in the documentation about point_direction not updating every frame, but I am going to try it. I have been looking for an easy way to make an enemy or a bullet move toward the player but not chase the player.

I know one way i can do it is to create a variable in the bullets create event that equals player.x and y, then use that for the point it seeks, this way the point it is going to is the point created when the bullet was created, so it goes to that fixed point where the player was, allowing the play to dodge the bullet or enemy.
 

TheouAegis

Member
I don't know why you neck wrote this post, but whatever. you don't need to store anything in the bullet. Just specify its direction and speed in the create event or at the moment it is created. If you don't want something to change every step, then don't.
 
Top