How do i make enemies that attack when a player comes into the sensor

please help i want enemies like phantasma has in karma fighters

3 Likes

Hello, @KingDemonlordIV.
I will try to explain this as best as possible.
First, you want to create a AI team. This is how you do it.


Go to Environment → Global Variable → General → Add New → Your key (Your AI Team) → Data Type (Put player) → Value (Put you Computer AI Team #)
The Value and Key is up to you.


Sorry if I am bad at explaining, I am not good at it. lol.


Next, you want to go to Environment → Player Types → Add New.

You want to add your enemy ai team name. You also want to add a player team if there isn’t one already. Then, you want to go into both of them and set their Diplomacy to Hostile.


Next, to spawn your AI through a script. This is easier in my opinion.


Create a script to spawn your ai, for my game I called it AI Spawn. Next, you want to choose this action, create unit at position. Fill out everything. This is what is should say. create YourUnitName type for entity (Pick your team that you created.) at position facing 0 radians.


Lastly, go into your initialize script to add this action.
Here is the action you want to select. assign player type.
You need to click your enemy team name then go to the next red part and put your enemy team name there too. Also, make sure to add your player to the player team. Hope this helps. Also, sorry for explaining this bad. I am not a good explainer.

2 Likes

._. Calms walks out of this really important discussion

2 Likes

hi mommmm i am nathanw_ISAf

1 Like

thank you again corey

2 Likes

wow he made a whole para
graph

2 Likes

@CoreyPlaysYT thank you. i have 2 more problems, 1. what do i do to the ai part when making an enemy so that it will get close to the player. 2. how do i make it so when players die they keep their items

2 Likes

Hello, @KingDemonlordIV!
I hope what I said helped in the first part. Anyways, to your 2 questions.
So, for the first one, can you maybe explain that a little more. I didn’t really understand that. For your 2nd one. Just take out the drop all of triggering units items if you have that in one of your death scripts. Hope this helps!

2 Likes

thank you. the first one, i want it so the enemies with melee attacks will sense the player from a distance and come close enough to hit them, but i have not been able to make it so the fight/flee range works with the sensor. they get disinterested unless the player is in the fight/flee range, but i want the to come closer

2 Likes

Hello, @KingDemonlordIV.
I am sorry. I don’t know how this would work. I understand what you mean though. I will make some test projects to see if I know how to do this. If I figure it out, I will let you know!

2 Likes

Hello, @KingDemonlordIV.
I might have found a way to do this. I have been testing it and it sometimes works. It will be too hard to explain so, if you want, you can add me as a contributor. You don’t have to as some people are nervous because they don’t want their game to get messed up. If you want to, here is my username. CoreyPlaysYT

2 Likes

ok i will and yes i am a little nervous but this is my first game for modd.io, i have been working on a free roam game(3d) on my side time but i have taken a long break, but anything to help this game is appreiciated

2 Likes

you should be added tell me if you are not

2 Likes

Mk. I will check it out and see if it works!

2 Likes

I am not added. I just checked.

2 Likes

hmm i might have to refresh the page and re-add you

2 Likes

there that should do it

2 Likes

Okay. I am going to finish my homework first. Lol.

2 Likes

k that is fine i have to do the same

2 Likes

@KingDemonlordIV .
Sorry, I was trying but it wouldn’t work. I removed the script that I made because it didn’t work. I do like the game though! It’s pretty nice actually. You can go ahead and remove me from the contributor if you want. I hope you game goes well!

2 Likes