void ABaseWeapon::fireTargetingRaycasts() { const int32 RandomSeed = FMath::Rand(); FRandomStream WeaponRandomStream(RandomSeed); const float CurrentSpread = 2.0f; const float SpreadCone = FMath::DegreesToRadians(CurrentSpread * 0.5f); FVector Up_StartTrace = (MyPawn->GetActorLocation() + (MyPawn->GetActorForwardVector() * 500)) + (MyPawn->GetActorUpVector() * 30); FVector Up_Dir = MyPawn->GetActorForwardVector(); FVector Up_EndTrace = Up_StartTrace + Up_Dir * (WeaponConfig.WeaponRange); FVector Down_StartTrace = (MyPawn->GetActorLocation() + (MyPawn->GetActorForwardVector() * 500)) + (MyPawn->GetActorUpVector() * -30); FVector Down_Dir = MyPawn->GetActorForwardVector(); FVector Down_EndTrace = Down_StartTrace + Down_Dir * (WeaponConfig.WeaponRange); FVector Left_StartTrace = (MyPawn->GetActorLocation() + (MyPawn->GetActorForwardVector() * 500)) + (MyPawn->GetActorRightVector() * -30); FVector Left_Dir = MyPawn->GetActorForwardVector(); FVector Left_EndTrace = Left_StartTrace + Left_Dir * (WeaponConfig.WeaponRange); FVector Right_StartTrace = (MyPawn->GetActorLocation() + (MyPawn->GetActorForwardVector() * 500)) + (MyPawn->GetActorRightVector() * 30); FVector Right_Dir = MyPawn->GetActorForwardVector(); FVector Right_EndTrace = Right_StartTrace + Right_Dir * (WeaponConfig.WeaponRange); FName TraceTag("TraceTag"); FCollisionQueryParams TraceParams(TraceTag, true, this); TraceParams.bTraceAsyncScene = true; TraceParams.bReturnPhysicalMaterial = true; TraceParams.AddIgnoredActor(MyPawn); TraceParams.TraceTag = TraceTag; GetWorld()->LineTraceSingleByChannel(Up_hit, Up_StartTrace, Up_EndTrace, COLLISION_TARGET, TraceParams); //DrawDebugLine(GetWorld(), Up_StartTrace, Up_EndTrace, FColor::Cyan, false, -1.0f, 0, 2); GetWorld()->LineTraceSingleByChannel(Down_hit, Down_StartTrace, Down_EndTrace, COLLISION_TARGET, TraceParams); //DrawDebugLine(GetWorld(), Down_StartTrace, Down_EndTrace, FColor::Cyan, false, -1.0f, 0, 2); GetWorld()->LineTraceSingleByChannel(Left_hit, Left_StartTrace, Left_EndTrace, COLLISION_TARGET, TraceParams); //DrawDebugLine(GetWorld(), Left_StartTrace, Left_EndTrace, FColor::Cyan, false, -1.0f, 0, 2); GetWorld()->LineTraceSingleByChannel(Right_hit, Right_StartTrace, Right_EndTrace, COLLISION_TARGET, TraceParams); //DrawDebugLine(GetWorld(), Right_StartTrace, Right_EndTrace, FColor::Cyan, false, -1.0f, 0, 2); }
void NSFTraceLog::addTrace(const NSFString& type, const NSFString& tag1, const NSFString& data1, const NSFString& tag2, const NSFString& data2, const NSFString& tag3, const NSFString& data3) { // If logging is not enabled, then return without action if (!enabled) { return; } NSFXMLElement* trace = NULL; try { // Lock to prevent events from being added to the queue with timestamps out of order LOCK(traceLogMutex) { // Create the new trace element trace = new NSFXMLElement(TraceTag()); // Add the time trace->addChildElementBack(new NSFXMLElement(TimeTag(), toString(NSFTimerThread::getPrimaryTimerThread().getCurrentTime()))); // Add a trace for the type NSFXMLElement* typeTrace = new NSFXMLElement(type); trace->addChildElementBack(typeTrace); // Add the new data under the type element; typeTrace->addChildElementBack(new NSFXMLElement(tag1, data1)); if (!tag2.empty()) typeTrace->addChildElementBack(new NSFXMLElement(tag2, data2)); if (!tag3.empty()) typeTrace->addChildElementBack(new NSFXMLElement(tag3, data3)); eventHandler.queueEvent(traceAddEvent.copy(true, trace)); } ENDLOCK; } catch(...) { // If unable to add a trace, just do nothing, because calling the exception handler may result in an infinite loop delete trace; } }