dimanche 2 juin 2019

[Unreal Engine] Enemy artificial intelligence and behaviors

It's a continuation of the 3D "Demon Soul Character" and the dialog system projects

The subject is to create a enemy actor , for that I implement a behavior tree with C++ and blueprint.

Conception

The enemy will use this state machine





At first the enemy will patrolling (patrol state) , when he detect the player , he will run to him (Chassing State) , and finally when the enemy is close enough the player, he will attack the player

Patrol

During the patrol , waypoints will be randomly generated around the enemy. This will make the enemy walk around his position and try to cover many area.

When enemy see the player he will enter the "chase state"

Chase 

During the state, the enemy will pursue the player and try to be closer to the player. To avoid the enemy to be very near the player. Player character have a "sphere " around him , when the enemy enter this sphere , that mean he is close enough to attack so he enters the "attack state"

Chase 


Attack

In video game, enemy are no too aggressive that why the enemy is not too aggressive

- On the first stage the enemy can turn around the player or stay idle

Strafe


- After this stage, enemy can attack the player or block.. enemy have to attack : one basic and another one when he jumps to attack the player ("run attack") . The attack are select randomly. If the enemy is behind the player, he will 100% attack the player, that will add strategy to the game

Attack the player


Block




dimanche 14 avril 2019

[C++ OpenGL] Pathfinding : Dijkstra and A*

I implemented two of the most popular technique use in video game to help a artificial agent navigates on the map : Dijkstra and A *

Dijkstra

Dijkstra is use so for a pathfinding process. The idea of the Dijkstra algorithm to start from the start node and scan all his neighbor until its find the destination route.

Dijkstra advantage it that he will always find the shortest route, but his weakness is that Dijkstra over exploring, and sometime we don't need it

A *

A* is I think it's the most use pathfinding technique in video game. Like on the previous subject, Dijkstra is good but it's over exploring to get the shortest path, it's can be an optimization issue

Sometime we don't need the shortest path, we just need a path to the destination, and that what A* does.

The main difference with A* and Dijkstra is A* Heuristic system which influence a lot about calculation of the path. On my project I use distance between the current scan node and the destination

Demo

He is the map



And some results





Source code

Link to this project : https://github.com/NicolasBunn/Pathfinding

lundi 1 avril 2019

[C++ OpenGL] Autonomously Moving Actor

Introduction

This projet made in C++ OpenGL show some 2D gemotry mathematics and "Steering Behaviors" IA

On this project ,the user can move a triangle player actor and give some commands to an ia actor

Here is the mains behaviors for the Ia actor

Seek

The agent goes to a specific location



Wander

The agent randomly patrol a round his location


Flee

When the player try to reach the agent, he goes to the opposite direction




Follow Path

The agent follow a way point node which are sort in a specific ordr . If the agent is near one a waypoint, he directly go to this waypoint instead to go from the first way point



Pursue

When an agent try to catch the player, if he goes to the current location, it is not optimize solution because the player is constantly moving. So one solution is to try to anticipate where the player is going, for doing that, the agent will try the "direction vector " that the player goes.

When the agent is close enough of the player , he will go directly on the player position.



Wall Avoidance

When a agent try to goes to a destination, if there is a wall between them, naturally the agent can't go there. The solution is to avoid the wall and goes to the destination. The agent will rotate and will find a path which are not colliding with the wall, then he goes to the destination and finally try to reach the final destination



Source and version can be found on this github : https://github.com/NicolasBunn/MovingAgent

samedi 23 février 2019

Fuzzy Logic : What the best weapon to pick

Introduction

Fuzzy logic is artificial intelligence use in video game. The specificity of the fuzzy logic is to compute a desiraiblity value for very specific case instead of normal checking to enable state

Here is an example where the fuzzy logic can useful

Project : Which weapon choose again player ?

In a shooter game, an AI actor can have multiple weapons, but which weapon choose to fight efficiently again player

For this project, I create 3 weapons

- Shotgun : Very efficient on a close combat insofar as the spread of weapon, but useless for long distance because the shell spread so the damage is minimal form afar

 - Rocket Launcher : Very efficent on mid combat, not  efficient close because the damage explosion can hurt the player , and not efficient form far because the rocket is slow so the enemy can avoid the rocket

- Sniper Rifle : Very efficient for far combat , efficient on middle. Not efficient on close combat, because the time of reloading a sniper is very long

The selection of the weapon will using 2 data

- Distance from the player
- Munition in the weapon

For each of the 2 data, multiples rules will be create

- Target Close & Lot of ammo, Target Close & Correct amount of ammo, Target Close & low ammo
- Target Mid & Lot of ammo, Target Mid & Correct ammount of ammo...

Diagram

Here is 2 diagrams for the 2 datas

Distance
The target is

- Close : 0 : 25 meters
- Middle : 25 300 meters
- Far 150 1000

You can note that a target can middle and far at the same time ! But that is the fuzzy logic is not stuck in one state, but give values for each state

Ammo

 The target is

- Low ammo: 0 : 10 ammo
- Correct ammo : 10 30 ammo
- Lot ammo 30 100

 Demonstraction

On this project the user can enter the distance of the target and the munition of each weapon (rocket,shotgun , sniper)

Here are the result



For a ditance of  50 meter to the target the best weapon is the shotgun



For a distance of 150 meter to the target the best weapon is the rocket launcher



For a distance of 300 meter to the target the best weapon is the sniper rifle

Link to this project : https://github.com/NicolasBunn/FuzzyLogic


dimanche 20 janvier 2019

[Action Game] 3D "Demon Soul" Character

This a project about a character which look like a Demon Soul (or Dark Soul) Gameplay.

This demo is a prototype and will be include I hope in a larger project (by instance the Quest system for the next project) All Assets are from the free Paragon of Unreal Engine. All this project uses C++ and Blueprint

Like Demon Soul the character have 3 stats : Health , Magic and Stamina. Here is a recap of all specific action


Commands

Left Stick : Move the character
Right Stick : Move the camera
Left Right Pad : Change Item
Up Down : Change Spell
Button 1 : Run or dash
Button 2 : Interact
Right Stick Button : Target Mode to lock target
Start : Open Menu
Left Shoulder button : Use Spell
Right Shoulder button : Attack




The scene


Run

Run give the player to move faster but it's use stamina, so when the character is running, it's uses stamina. Stamina is load during a Tick Event and when the character is not running and not performing action which use stamina

Attack

Kwang character can attack enemy with his sword. Attack use stamina (which is reload if the character didn't perform action which are using stamina). This project include a simple combo system, Kwang can perform a 3 hit combo

Attack


Locking

Locking a specific target is essential. Player can lock an enemy character if he near enough a target, if there a multiple targets, the lock will take the most near target.

When the target is lock, the player can run around the target. Press again the lock button will disable the target mode

A mesh is display above the enemy to know he is lock. Moreover you can the life of the ennemy


Spell

The player can use the heal to regain life point. A spell use MP Points, mp will be refill during time.

Healing spell


Looting

Character loot items when he kills enemy. To simulate Loot, the project have an inventory where player can stock : Health Potion and Magic Potion.

Loot




Menu Content

Player can level Up his stats, like Dark Soul, the player have to use his experience point (or soul point) to increase his stat, every time the player increases stats, the next quantity for level up will be increase

Level Up Stats


Player can also equips weapon and armor to improve stats

Equipment


New action for player will be include soon !

Please free to contact me to test this project on this email : nicolasbunn@gmail.com

[Unreal Engine 4] Dialog and quests systems

This project have 2 parts

- First part : The player can talks to a NPC Character, this character will give a quest (which the player can refuse)

- Second part : If the player accepts the quest, a new quest will be enable . This quest is very easy the player have to collect "unreal " coins.

Description

A NPC is on the scene, if the player come close enough, he will able to talk the NPC

Talk Action

 The NPC will the player a quest to complete

Player can choose to accept or refuse the quest


 If the player accepts the quests, the quest will begin, the player have to collect the coin

The quest begins !
When the player collects coins, a message will be display to keep the player inform about the progression

Update Quest
The quest is over !

 The player talk to the npc to finish the quest

The npc rewards the player with exp !


Don't hesitate to ask on my personnal email : nicolasbunn@gmail.com to test this mini project !

Thanks