Basic enemy AI

how would i use animations with this

The enemy entity has a prepared anim component and anim state graph. You basically only have to apply your own character and animations.

HUD means “Heads up display”

how would i make it so it would hit with its hand instead of using a bullet

If it is an animated entity (moving entity) you can use the same method as I do for the bullet (collision check).

**how do i make the enimy chase me
**

Hi @johngamedev and welcome!

This is already part of the example project. Does this not work for you?

I basically rotate the enemy entity in the direction of the target entity and then move the enemy entity in the forward direction.

how do i make a gun for my player that shoots

1 Like

If you want to make a player that shoots please ask in another related discussion if there isn’t enough information or ask your own question as this discussion is enemy AI topic.

1 Like

Hey man thank you so much for this Enemy AI!

But I need help with this problem

the Enemy AI does chase me but it’s running backwards.

Hi @Drake_Aurin!

Your character need to be a child entity of the AI entity. Then you can rotate this child entity 180 degrees. Please check the setup of the example project, because it’s already prepared.

2 Likes

Hello, I tried to rotate the Parent 180 but it’s still moving backwards hahahahaha.
I dont know what’s wrong maybe you can check?

https://playcanvas.com/editor/scene/1759892

Oh wait nvm i found out that the root hip bone is not Parented in asset Model!
Thanks again for this project!

1 Like

hi i know what to do but i do not know how to code at all and i have know how to make the ai look at me and then walk to me

This is already part of the example project.

Have you tried using the AI in your own project?

The project is updated to version 1.2.

This update supports multiple targets. The enemy chooses the closest target as the current target.

Changelog:

  • Merged functions updateView and updateAudible into updateTarget
  • Targets need Target tag
  • Audible targets need Audible tag
1 Like

Feature Request - Targeting Horror Games

Enemy teleport in a random nearby room and looks and if the player is in view the enemy will chase the play for a specific number of seconds before disappearing, waiting a cooldown, and repeating.

Thanks for your request.

Unfortunately, it’s unlikely I will add this as this AI is more realistic.

What you could do is modify an existing state. In this case I would suggest to use the Search state for this.

Below I have add some suggestions to achieve this.

// Search state
Enemy.prototype.Search = function (dt) {
    this.enemyTarget = null;
    this.enemySpeed = this.searchSpeed;

    this.enemySearchTimer -= dt;
    if (this.enemySearchTimer <= 0) {
        this.enemySearchTimer = Math.random() * this.chaseTime;
        // Add here some code to teleport the enemy entity to another position //
        this.getRandomDestination(this.enemyOrigin); // Replace this.enemyOrigin with the current position //
    }
};

Is there a way to make the ai climb/jump on some obstacles and avoid others? maybe by using tags?

Everything is possible, but I don’t think this is easy to achieve.