Тёмный

C++ AI Perception | Make AI Look At Any Bone | AI Perception to Custom Sockets - UE4 C++ Tutorial 

Pranjal Bhattacharjee
Подписаться 613
Просмотров 3,9 тыс.
50% 1

This is a UE4 C++ tutorial video that shows you how to setup the "AIPerceptionComponent" in C++ and how to change the Sight Targets / View Targets for the perception system at runtime.
#UE4 AI #AI Perception

Опубликовано:

 

21 июл 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@letenebrae3164
@letenebrae3164 2 года назад
Really great content, man
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 2 года назад
Thanks......🙂
@mb.3d671
@mb.3d671 3 года назад
Keep it up, ai is very hard but you made it simple
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 3 года назад
Thank you
@MrVladiebaddie
@MrVladiebaddie Год назад
Kind of wish there was more C++ stuff for UE 5.0+. Thanks for the video it helped me out a ton even if it's a bit dated at this point.
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 Год назад
Let me know if you need the updated code for ue5
@MrVladiebaddie
@MrVladiebaddie Год назад
@pranjalbhattacharjee5601 I'm good. I have it updated and running with no issues. It might break once I try to hook it up to a behavior tree.
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 Год назад
@@MrVladiebaddie It should also work correctly with behavior trees.
@shannenmr
@shannenmr 2 года назад
Thoughts on setting it up to trace to multiple bones and depending how many it see's the strength of the detection + increase the strength of the detection if it see's the same bones or increasing amount of bones for an extended period of time. (Like if it can only trace to the right hand the initial strength is very low but if it continues to see the hand the strength increases ... and if it starts seeing more like the right arm it increases the strength alot more)
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 2 года назад
This should be simple to implement but such a complex detection system would be difficult to convey to the player......I watched a gdc talk on the human ai of the last of us and there they said that initially they tried complex detection models but it was too confusing for the players and the final version just uses 3 line traces either to the chest or the head
@shannenmr
@shannenmr 2 года назад
@@pranjalbhattacharjee5601 Similar to the discussion in the GDC Talk - Modeling AI Perception and Awareness in Splinter Cell: Blacklist I think my though boils down to if the AI can trace to your 1 bone because its showing through a slit or if its say you hand sticking out slightly you probably don't want it to react or at-least react quickly, but say you start exposing more then its seeing more + indicating there is movement which would cause "someone" to be more aware of it. In regards to conveying it to a player I would say most straight forward is Barks, so something like: See 1 bone bone the AI might say say "hey was there just movement over there / what's over there" and look in the direction + change their perception from being short range and broud to longer range and narrow. See 2 bones the AI says "hey you over there come out / who's that over there" and change perfection + maybe shoot a warning shot or continue to bark other similar things + maybe investigate. See 2 (one being major bone ) or more bones then full combat AI rules where it finds cover and calls for backup etc etc.
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 2 года назад
When the bot sees one bone the player might be behind cover but because of how the animations are setup one bone or may be a few bones are exposed.....if in this case the player is detected it would feel unfair to the player because the player was not given a better way to hide.....if your game has systems to give the player control over each and every bone then if the player gets detected it is because he/she did something wrong (ex: he had the option to fold his arm but he did not and got detected) otherwise such systems would only frustrate the player...... remember the bots are not there to behave realistically, they are there for the player's fun....so games always need to be player favouring and never make the player feel cheated..... emphasis on the word feel
@creygelz9535
@creygelz9535 Год назад
Thanks a lot for this! Although it only works if you use the same BaseCharacter for the AI and the Player. I'm forced to have different BaseCharacters for each. Is there a way to make that work? Been trying now for about 6h without success. Thanks a lot in advance for a response!
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 Год назад
Well there are no good reasons for having different base characters for the player and the ai but if you must do it then put the "can be seen from" function in the parent class for the player
@creygelz9535
@creygelz9535 Год назад
@@pranjalbhattacharjee5601 Thanks Pranjal! I already tried that. I might give it another go today. Could be a cpp plugin for the PlayerCharacter that acts as a child and is throwing off things. I'll comment if I succeeded. Thanks again.
@greengamerguy623
@greengamerguy623 3 месяца назад
I'm having a big problem with the Client not working the perception socket/bone can be changed but it doesn't attach please need help using 5.3
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 3 месяца назад
I am not sure I understand what you are saying but for the "can be seen from" function to work, all he characters need to inherit from the same base class
@D.Mario03
@D.Mario03 4 месяца назад
Can you make it so that it will look at different bones by itself and not at runtime from the player input ?
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 4 месяца назад
Yes that can be done.....
@ashwinj9879
@ashwinj9879 Год назад
Does this work on ue5.1?
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 Год назад
Use this for ue5.1 // Custom View Target For AIPerception Component bool ACharacterBase::CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor, const bool* bWasVisible, int32* UserData) const { static const FName NAME_AILineOfSight = FName(TEXT("TestPawnLineOfSight")); FHitResult HitResult; FVector SocketLocation = GetMesh()->GetSocketLocation(PerceptionTarget); const bool bHitSocket = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, SocketLocation, FCollisionObjectQueryParams(ECC_TO_BITFIELD (ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic)), FCollisionQueryParams(NAME_AILineOfSight, true, IgnoreActor)); NumberOfLoSChecksPerformed++; if (bHitSocket == false || (HitResult.GetActor() && HitResult.GetActor()->IsOwnedBy(this))) { OutSeenLocation = SocketLocation; OutSightStrength = 1; return true; } const bool bHit = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, GetActorLocation(), FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic)), FCollisionQueryParams (NAME_AILineOfSight, true, IgnoreActor)); NumberOfLoSChecksPerformed++; if (bHit == false || (HitResult.GetActor() && HitResult.GetActor()->IsOwnedBy(this))) { OutSeenLocation = GetActorLocation(); OutSightStrength = 1; return true; } OutSightStrength = 0; return false; }
@DavidRicardo97
@DavidRicardo97 Год назад
This looks a great tutorial but Perception is not running here. Perhaps i did some mistake or the content is outdated. Thank you anyway for sharing!
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 Год назад
Use this for ue5.1 // Custom View Target For AIPerception Component bool ACharacterBase::CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor, const bool* bWasVisible, int32* UserData) const { static const FName NAME_AILineOfSight = FName(TEXT("TestPawnLineOfSight")); FHitResult HitResult; FVector SocketLocation = GetMesh()->GetSocketLocation(PerceptionTarget); const bool bHitSocket = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, SocketLocation, FCollisionObjectQueryParams(ECC_TO_BITFIELD (ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic)), FCollisionQueryParams(NAME_AILineOfSight, true, IgnoreActor)); NumberOfLoSChecksPerformed++; if (bHitSocket == false || (HitResult.GetActor() && HitResult.GetActor()->IsOwnedBy(this))) { OutSeenLocation = SocketLocation; OutSightStrength = 1; return true; } const bool bHit = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, GetActorLocation(), FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic)), FCollisionQueryParams (NAME_AILineOfSight, true, IgnoreActor)); NumberOfLoSChecksPerformed++; if (bHit == false || (HitResult.GetActor() && HitResult.GetActor()->IsOwnedBy(this))) { OutSeenLocation = GetActorLocation(); OutSightStrength = 1; return true; } OutSightStrength = 0; return false; }
@DavidRicardo97
@DavidRicardo97 Год назад
@@pranjalbhattacharjee5601 I'm using 4.27. My AIControllerBase is running BeginPlay but isn't running OnPossess Event, for some reason.
@DavidRicardo97
@DavidRicardo97 Год назад
Ok, I've found the bug and it's working. Thank you!
@pranjalbhattacharjee5601
@pranjalbhattacharjee5601 Год назад
@@DavidRicardo97 do you have a blueprint version of the on possess event....??....if so call the parent function first before the blueprint logic
Далее
Detection By Affiliation - Ue4 C++ Tutorial
6:39
Просмотров 5 тыс.
Ue5 C++ Tutorial - Attach AI Perception to Head Bone
3:41
Tom🍓Jerry 😂 #shorts #achayanarmyfamily
00:14
Просмотров 14 млн
Strong cat !! 😱😱
00:19
Просмотров 2,6 млн
Я ПОКУПАЮ НОВУЮ ТАЧКУ - МЕЧТУ!
39:05
The Most Legendary Programmers Of All Time
11:49
Просмотров 538 тыс.
How to Render Faster In Blender Cycles
9:11
Просмотров 25 тыс.
Git Tutorial For Dummies
19:25
Просмотров 1 млн
The moment we stopped understanding AI [AlexNet]
17:38
Просмотров 749 тыс.
War Within Pre-patch - WHAT'S NEW? 11.0
14:40
WTF Is? AI: Focus Nodes in Unreal Engine 4 ( UE4 )
5:49
Tom🍓Jerry 😂 #shorts #achayanarmyfamily
00:14
Просмотров 14 млн