# The Impact Point position returned by capsule collision is incorrect. Can anyone explain why?

**URL:** <https://forums.unrealengine.com/t/the-impact-point-position-returned-by-capsule-collision-is-incorrect-can-anyone-explain-why/2118317>\
**Category:** Programming & Scripting\
**Tags:** climbing, unreal-engine, Physics, Collision, question\
**Created:** [November 12, 2024, 5:16pm UTC](https://forums.unrealengine.com/t/the-impact-point-position-returned-by-capsule-collision-is-incorrect-can-anyone-explain-why/2118317 "2024-11-12T17:16:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lezard1999](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lezard1999](https://forums.unrealengine.com/u/lezard1999)\
**Post date:** [November 12, 2024, 5:16pm UTC](https://forums.unrealengine.com/t/the-impact-point-position-returned-by-capsule-collision-is-incorrect-can-anyone-explain-why/2118317/1 "2024-11-12T17:16:57Z")

</div>

I’m making a character climbing system. When the character is in climbing mode, I generate a collision-detecting capsule in front of the character at every tick and sweep forward one unit distance to continuously detect wall collisions and handle the climbing problem of the character movement component.

In order to facilitate observation, I used a transparent wall for the character to climb, and drew a white detection capsule and a yellow Impact Point.

[image]  
 ![Normal Climbing](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/8/5e85e91269dfa600872407cc08d96b25c39cb9ff.gif)  
[When the character climbs normally, the Impact Point detected by the capsule is directly in front of the character capsule.]

Although the character can already start climbing up the wall, the problem is that when the character climbs and moves somewhere on a flat wall vertical to the ground, the Impact Point position in the HitResult structure returned by capsule collision detection sometimes changes. It’s very weird (as shown in the picture, the yellow point represents the Impact Point). This incorrect Impact Point leads to the incorrect Impact Normal (affecting the rotation direction of my character when climbing). Can someone tell me this? Why?

![Issue Climbing](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/5/3/d5368d1f4ddf3194be05f91a2c369c4c20b3cbb4.gif)

Here is my code：

‘’'cpp

void UALCMovementClimbObject::SweepAndStoreWallHits()  
{  
const FALCMovementClimbCondition& currentConditionSettings = GetCurrentClimbModeDA()-\>ClimbConditionSettings;

```
const FCollisionShape CollisionShape = FCollisionShape::MakeCapsule(currentConditionSettings.ClimbCapsuleTraceRadius,currentConditionSettings.ClimbCapsuleTraceHalfHeight);
const FVector StartOffset = ALCMovementComp->UpdatedComponent->GetForwardVector() * currentConditionSettings.CapsuleTraceStartOffset;
const FVector Start = ALCMovementComp->UpdatedComponent->GetComponentLocation() + FVector(0,0,currentConditionSettings.CapsuleTraceVerticalOffset) + StartOffset; 
const FVector End = Start + ALCMovementComp->UpdatedComponent->GetForwardVector();	// Avoid using the same Start/End location for a Sweep, as it doesn't trigger hits on Landscapes.

TArray<FHitResult> Hits;
bool HitWall = false;
HitWall= UKismetSystemLibrary::CapsuleTraceMultiForObjects(
	GetWorld(),
	Start,
	End,
	currentConditionSettings.ClimbCapsuleTraceRadius,
	currentConditionSettings.ClimbCapsuleTraceHalfHeight,
	currentConditionSettings.ClimbableObjectTypes,
	false,
	TArray<AActor*>(),
	EDrawDebugTrace::ForOneFrame,
	Hits,
	true
	);
	
if(ALCMovementComp->DebugRules.bEnableClimbObjectDebug)
{
	if (CollisionShape.IsCapsule())
	{
		float CapsuleRadius = CollisionShape.GetCapsuleRadius();
		float CapsuleHalfHeight = CollisionShape.GetCapsuleHalfHeight();

		DrawDebugCapsule(
			GetWorld(),
			Start,
			CapsuleHalfHeight,
			CapsuleRadius,
			FQuat::Identity,
			FColor::White,   
			false,           
			0.f,
			0,
			1
		);
		DrawDebugCapsule(
			GetWorld(),
			End,
			CapsuleHalfHeight,
			CapsuleRadius,
			FQuat::Identity,
			FColor::White,    
			false,           
			0.f,
			0,
			1
		);
	}
	if(HitWall)
	{
		for(auto x:Hits)
		{
			DrawDebugPoint(GetWorld(),x.ImpactPoint,15,FColor::Yellow,false,0,0);
			DrawDebugPoint(GetWorld(),x.Location,15,FColor::Orange,false,0,0);
			DrawDebugDirectionalArrow(GetWorld(),Start, x.Location,1.5,FColor::Purple,false,0,0,1);
		}
	}
}
ClimbableSurfacesTracedResults = HitWall ? Hits : TArray<FHitResult>();

```

}  
‘’’

---

<div class="post-metadata">

**Author:** ![lezard1999](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lezard1999](https://forums.unrealengine.com/u/lezard1999)\
**Post date:** [November 13, 2024, 4:35am UTC](https://forums.unrealengine.com/t/the-impact-point-position-returned-by-capsule-collision-is-incorrect-can-anyone-explain-why/2118317/2 "2024-11-13T04:35:35Z")

</div>

Fixed, it turns out I was wrong when doing Computes Normal.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [December 13, 2024, 4:36am UTC](https://forums.unrealengine.com/t/the-impact-point-position-returned-by-capsule-collision-is-incorrect-can-anyone-explain-why/2118317/3 "2024-12-13T04:36:18Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
