keywords: UE4, 投射, 延长, 向量, 延伸

代码:

float Len = FMath::Sqrt(100 * 100 + 100 * 100);
FVector Loc = FVector(100.f, 100.f, 0.f) + FRotator(0.f, 45.f, 0.f).Vector() * Len;

结果:

Loc = {X=200.f, Y=200.f, Z=0.f}

FRotator::Vector()对应的蓝图函数为GetRotationXVector

=================================

例子2:

float Len = FMath::Sqrt(100 * 100 + 100 * 100);
FVector Loc1 = FVector(0.f, 0.f, 0.f) + FRotator(0.f, 45.f, 0.f).Vector() * Len;
FVector Loc2 = FVector(0.f, 0.f, 0.f) + FRotator(0.f, 135.f, 0.f).Vector() * Len;
FVector Loc3 = FVector(0.f, 0.f, 0.f) + FRotator(0.f, 225.f, 0.f).Vector() * Len;
FVector Loc4 = FVector(0.f, 0.f, 0.f) + FRotator(0.f, 315.f, 0.f).Vector() * Len;

结果:

Loc1 = {X=100.f, Y=100.f, Z=0.f}
Loc2 = {X=-100.f, Y=100.f, Z=0.f}
Loc3 = {X=-100.f, Y=-100.f, Z=0.f}
Loc4 = {X=100.f, Y=-100.f, Z=0.f}