public void Normalize() { fint num = FVector3.Magnitude(this); if (num.raw > 1) { this /= num; } else { this = FVector3.zero; } }
protected override void OnUpdate() { if (walking) { FVector3 nextPoint = path[pathIndex]; nextPoint.y = voxelComponent.position.y; voxelComponent.position = FVector3.MoveTowards(voxelComponent.position, nextPoint, SimulationTime.deltaTime * speed); if (voxelComponent.position == nextPoint) { pathIndex++; if (pathIndex == path.Count) { path.Clear(); pathIndex = 0; walking = false; } } } }
public static FVector3 Cross(FVector3 lhs, FVector3 rhs) { return(new FVector3(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x)); }
// // Static Methods // public static fint Angle(FVector3 from, FVector3 to) { return(FMath.Acos(FMath.Clamp(FVector3.Dot(from.normalized, to.normalized), -fint.one, fint.one)) * FMath.Rad2Deg); }
public void Scale(FVector3 scale) { this.x *= scale.x; this.y *= scale.y; this.z *= scale.z; }
public static FVector3 Scale(FVector3 a, FVector3 b) { return(new FVector3(a.x * b.x, a.y * b.y, a.z * b.z)); }
public static FVector3 Reflect(FVector3 inDirection, FVector3 inNormal) { return(fint.CreateFromInt(2) * FVector3.Dot(inNormal, inDirection) * inNormal + inDirection); }
public static FVector3 Min(FVector3 lhs, FVector3 rhs) { return(new FVector3(FMath.Min(lhs.x, rhs.x), FMath.Min(lhs.y, rhs.y), FMath.Min(lhs.z, rhs.z))); }
public static FVector3 Lerp(FVector3 from, FVector3 to, fint t) { t = FMath.Clamp01(t); return(new FVector3(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t, from.z + (to.z - from.z) * t)); }
public static FVector3 Exclude(FVector3 excludeThis, FVector3 fromThat) { return(fromThat - FVector3.Project(fromThat, excludeThis)); }
public static fint Dot(FVector3 lhs, FVector3 rhs) { return(lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z); }
public static fint Distance(FVector3 a, FVector3 b) { FVector3 vector = new FVector3(a.x - b.x, a.y - b.y, a.z - b.z); return(FMath.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z)); }