44 lines
1.4 KiB
Lua
44 lines
1.4 KiB
Lua
local Ex08_StructAndTrace = UnLua.Class()
|
|
function Ex08_StructAndTrace.ReceiveBeginPlay(self)
|
|
self.Overridden.ReceiveBeginPlay(self)
|
|
self._tmpStart = UE.FVector(0, 0, 0)
|
|
self._tmpEnd = UE.FVector(0, 0, 0)
|
|
self._tmpHit = UE.FHitResult()
|
|
self._ignoreActors = UE.TArray(UE.AActor.StaticClass())
|
|
self._ignoreActors:Add(self)
|
|
end
|
|
function Ex08_StructAndTrace.ComputeVectorMath(self)
|
|
local a = UE.FVector(3, 4, 0)
|
|
local b = UE.FVector(0, 0, 12)
|
|
local c = a:Add(b)
|
|
local dot = a:Dot(b)
|
|
local dist = UE.FVector.Dist(
|
|
UE.FVector(0, 0, 0),
|
|
c
|
|
)
|
|
return c:Size(), dot, dist
|
|
end
|
|
function Ex08_StructAndTrace.TraceForward(self, distance)
|
|
local origin = self:K2_GetActorLocation()
|
|
self._tmpStart:Set(origin.X, origin.Y, origin.Z)
|
|
self._tmpEnd:Set(origin.X + distance, origin.Y, origin.Z)
|
|
local bHit, hit = UE.UKismetSystemLibrary.LineTraceSingle(
|
|
self,
|
|
self._tmpStart,
|
|
self._tmpEnd,
|
|
UE.ETraceTypeQuery.TraceTypeQuery1,
|
|
false,
|
|
self._ignoreActors,
|
|
UE.EDrawDebugTrace.None,
|
|
self._tmpHit,
|
|
true
|
|
)
|
|
return bHit, hit.Distance, hit.ImpactPoint
|
|
end
|
|
function Ex08_StructAndTrace.TeleportTo(self, x, y, z)
|
|
local target = UE.FVector(x, y, z)
|
|
local bMoved = self:K2_SetActorLocation(target, false, self._tmpHit, true)
|
|
return bMoved
|
|
end
|
|
return Ex08_StructAndTrace
|