Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IN HEADER:
- public:
- //Override - Returns position/direction of eyes(it is an added socket to the head)
- UFUNCTION(BlueprintCallable, Category = Actor)
- virtual void GetActorEyesViewPoint( FVector& OutLocation, FRotator& OutRotation ) const;
- //Override - Are we seen?
- virtual bool CanBeSeenFrom(
- const FVector& ObserverLocation,
- FVector& OutSeenLocation,
- int32& NumberOfLoSChecksPerformed,
- float& OutSightStrength,
- const AActor* IgnoreActor = NULL
- ) const;
- IN CPP:
- //Override - Returns position/direction of eyes(it is an added socket to the head)
- void AYourCharacterClass::GetActorEyesViewPoint( FVector& OutLocation, FRotator& OutRotation ) const
- {
- OutLocation = GetMesh()->GetSocketLocation("eye");
- OutRotation = GetMesh()->GetSocketRotation("eye");
- }
- //Tests if the Head,Shoulder,Hands,Pelvis and Feet are seen or not, if either is true, returns true.
- bool AYourCharacterClass::CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor) const
- {
- static const FName NAME_AILineOfSight = FName(TEXT("TestPawnLineOfSight"));
- FHitResult HitResult;
- TArray<FName> SocketsToCheck = {"head","upperarm_l","upperarm_r","hand_l","hand_r","pelvis","foot_l","foot_r"};
- FString asd = FString::FromInt(SocketsToCheck.Num());
- if(GEngine){
- GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Yellow, asd);
- }
- for (int i = 0; i < SocketsToCheck.Num(); i++)
- {
- FVector socketLocation = GetMesh()->GetSocketLocation(SocketsToCheck[i]);
- //DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);
- DrawDebugLine(GetWorld(), ObserverLocation, socketLocation, FColor::Red, false, -1.0f, 0.0f, 4.0f);
- const bool bHitSocket = GetWorld()->LineTraceSingleByObjectType(
- HitResult, ObserverLocation, socketLocation
- , FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic)) // << Changed this line
- , FCollisionQueryParams(NAME_AILineOfSight, true, IgnoreActor)
- );
- NumberOfLoSChecksPerformed++;
- if (bHitSocket == false || (HitResult.Actor.IsValid() && HitResult.Actor->IsOwnedBy(this))) {
- OutSeenLocation = socketLocation;
- OutSightStrength = 1;
- return true;
- }
- }
- OutSightStrength = 0;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement