Skip to content
Snippets Groups Projects
Commit bae1f6a8 authored by Qurabi's avatar Qurabi
Browse files

Das physikalische Gehen ist fertig.

parent 04fccf59
No related branches found
No related tags found
No related merge requests found
......@@ -363,17 +363,22 @@ void AVirtualRealityPawn::Tick(float DeltaSeconds)
Super::Tick(DeltaSeconds);
MyDeltaSeconds = DeltaSeconds;
SetCapsuleColliderCharacterSizeVR();
//if (IsColliderOnGround()&&IsPhysMoving) {
// FVector CurrentCameraPosition = GetCameraComponent()->GetComponentLocation();
// FVector DirectionVector = CurrentCameraPosition - LastCameraPosition;
// DirectionVector.Z = 0.0f;
// FHitResult FHitResultPhys;
// CapsuleColliderComponent->AddWorldOffset(DirectionVector, true, &FHitResultPhys);
// if (FHitResultPhys.bBlockingHit) {
// RootComponent->SetWorldLocation(LastPawnPosition, true);
// }
//
//}
if (IsColliderOnGround()) {
FVector CurrentCameraPosition = GetCameraComponent()->GetComponentLocation();
FVector DirectionVector = CurrentCameraPosition - LastCameraPosition;
DirectionVector.Z = 0.0f;
FHitResult FHitResultPhys;
CapsuleColliderComponent->AddWorldOffset(DirectionVector, true, &FHitResultPhys);
if (FVector::Distance(FHitResultPhys.ImpactPoint, CapsuleColliderComponent->GetComponentLocation())<CapsuleColliderComponent->GetScaledCapsuleRadius()) {
FVector DiffFHitResultPhysLocationAndCapsuleCollider = FHitResultPhys.ImpactPoint - CapsuleColliderComponent->GetComponentLocation();
float InsideDistance = CapsuleColliderComponent->GetScaledCapsuleRadius() - FVector::Distance(FHitResultPhys.ImpactPoint, CapsuleColliderComponent->GetComponentLocation());
RootComponent->AddLocalOffset(DiffFHitResultPhysLocationAndCapsuleCollider.GetSafeNormal()*InsideDistance*DeltaSeconds, true);
}
}
PhysMoving(DeltaSeconds);
......
......@@ -132,7 +132,7 @@ private:
float GravitySpeed = 0.0f;
bool IsPhysMoving = false;
FHitResult CreateLineTrace(FVector Direction, const FVector Start, bool Visibility);
float NewRadius = 32.0f; FVector LastCameraPosition; FVector LastPawnPosition;
float NewRadius = 40.0f; FVector LastCameraPosition; FVector LastPawnPosition;
float ColliderHalfHight = 96.0f; FHitResult HitResults; FHitResult HitResultsPhysicaly; float MyDeltaSeconds = 0.0f;
void SetCapsuleColliderCharacterSizeVR(); void PhysMoving(float DeltaTime); bool IsColliderOnGround(); void VRClimbStepUp(float DeltaTime);
void InitRoomMountedComponentReferences();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment