Create the enemy with pathfinding AI #11

Closed
opened 2025-01-10 10:40:06 +01:00 by Squid8411 · 3 comments
Squid8411 commented 2025-01-10 10:40:06 +01:00 (Migrated from codeberg.org)

For our game, the enemy will need to be able to have a set of actions such as attacking and walking. The enemy will switch between these actions depending on its current state. Considering the time remaining and the scope of our project, we'll first be sticking to the primary function of making a cube that can move using a pathfinding AI. It will need to be able to walk around walls and, most importantly, not into anything.

For our game, the enemy will need to be able to have a set of actions such as attacking and walking. The enemy will switch between these actions depending on its current state. Considering the time remaining and the scope of our project, we'll first be sticking to the primary function of making a cube that can move using a pathfinding AI. It will need to be able to walk around walls and, most importantly, not into anything.
RobotZap10000 commented 2025-01-11 15:57:08 +01:00 (Migrated from codeberg.org)

The enemy does not need to have at attack state. The head will swivel about to face the player and attack them on sight. It should, however, have a rest state, where it doesn't move at all until we toggle it off. When walking, it must navigate around obstacles and walls while moving at a constant speed.

The enemy does not need to have at attack state. The head will swivel about to face the player and attack them on sight. It should, however, have a rest state, where it doesn't move at all until we toggle it off. When walking, it must navigate around obstacles and walls while moving at a constant speed.
RobotZap10000 commented 2025-01-23 09:39:31 +01:00 (Migrated from codeberg.org)

I have not yet properly described the exact process that the enemy must follow. Here it is below:

#Start in the resting state
var aggro : bool = False

func _ready():
    #Play the "Stand" animation to prevent it from T-posing

func _process():
    if aggro:
        WalkToPlayer()
    else:
        SearchForPlayer()

#Use this function to find the location of the player, create a path around obstacles and move along it at a constant speed.
#Once the enemy is close enough, change path to not approach the player too closely, but keep it moving
func WalkToPlayer():
    #CODE HERE

#Use this function to ensure that the enemy will only wake up when it has line of sight of the player.
#I would advise to have it cast a ray at the player every second or so, if it doesn't collide with a wall first, then you have line of sight.

func SearchForPlayer():
    #CODE HERE
    
    #Wake the enemy up
    aggro = True
I have not yet properly described the exact process that the enemy must follow. Here it is below: ``` #Start in the resting state var aggro : bool = False func _ready(): #Play the "Stand" animation to prevent it from T-posing func _process(): if aggro: WalkToPlayer() else: SearchForPlayer() #Use this function to find the location of the player, create a path around obstacles and move along it at a constant speed. #Once the enemy is close enough, change path to not approach the player too closely, but keep it moving func WalkToPlayer(): #CODE HERE #Use this function to ensure that the enemy will only wake up when it has line of sight of the player. #I would advise to have it cast a ray at the player every second or so, if it doesn't collide with a wall first, then you have line of sight. func SearchForPlayer(): #CODE HERE #Wake the enemy up aggro = True ```
RobotZap10000 commented 2025-01-27 10:46:48 +01:00 (Migrated from codeberg.org)

We have successfully added the pathfinding AI! The enemy also fires its guns when in line of sight of the player, but it currently has no effect on them.

We have successfully added the pathfinding AI! The enemy also fires its guns when in line of sight of the player, but it currently has no effect on them.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charlie/AUTOTANK#11
No description provided.