Skip to content
xg_55 edited this page Nov 8, 2016 · 1 revision
//Simulated gravity
float g = -9.8f;
FHitResult Hit;
if(UKismetSystemLibrary.LineTraceSingle_NEW(Engine.Instance.GetWorld(), position, position + new FVector(0, 0, -1000), 0, false, new AActor[] { }, EDrawDebugTrace.ForOneFrame, out Hit, true, new FLinearColor(), new FLinearColor(), 0))
{
	if(position.Z>Hit.ImpactPoint.Z)
	{
                    gv += g * timeElapsed;
                    position += 100 * gv * timeElapsed;
                    position.Z = Math.Min(position.Z, Hit.ImpactPoint.Z);
	}
	else
	{
                    position.Z = Hit.ImpactPoint.Z;
                    gv = 0.0f;
	}
}
Clone this wiki locally