So, as ive stated above, All i need is to make my enemy shoot a projectile straight ahead and then destroy when it hits something. I dont need the enemy to do anything else for the game I’m making. I was taught on how to make the player character shoot when pressing a key, but I have no idea if the same applies for the enemy character (except its an automatic shooting.) All i find in the internet is how to make a complex AI and I honestly just need something simple. I’m not really good at programming or blueprints so I’m doing the best I can to solve this.
For clarity, you want this:
After x seconds, AI shoots a projectile. Once that projectile hits something, destroy the projectile correct?
Yup. Is the last thing I need before I tackle other things for the project.
Ok, so for the timing thing, you need to have a function in your AI class, lets call it “shoot”. Then you use the “Set Timer by Function Name” node on Event Begin Play, where the Function Name is “shoot”, and how often to shoot.
This node calls the given function every X seconds.
For the projectile part, your projectile object needs to have a collision box. Then you use the “OnOverlapBegin” for the collision box, where it destroys self.
I can mock these up and post some screenshots if that would help.
if you dont mind. I will still try to set this up with the written text. AI class is the actor who will be shooting no? Trying to get that clear.
This is how I would set up my AI controller, though you will have to get the AI controlled pawn’s transform.
On begin play, start calling the “Shoot” function every 3 seconds (should probably be a variable). Then on shoot, just create the actor with the transform (includes location and rotation). Then let the projectile class do the rest. A good example of this is in the First Person Example demo.
Keep in mind that this is really simplified and you should think about adding animation/sound in the shoot function as well.
thanks. Now All i need is to figure out how to implement the shooting part. anyway thanks.,
Check out the first person demo that comes with the engine - it covers everything you need. Good luck! Feel free to post back here if you run into any issues.