[英]Sphere Trace For Objects in Unreal Engine C++
I added a new object channel named Point in Project Settings/Collision.我在项目设置/碰撞中添加了一个名为 Point 的新 object 通道。 Project Settings / Collision
项目设置/碰撞
I want to make Spehere Trace Single For Objects in C++.我想为 C++ 中的对象制作 Spehere Trace Single。 Basicly, i wanna do this in C++.
基本上,我想在 C++ 中执行此操作。 Blueprint Code (It works)
蓝图代码(有效)
I searched it for a while and i found this in DefaultEngine.ini: DefaultEngine.ini (Ln58)我搜索了一段时间,我在 DefaultEngine.ini 中找到了这个: DefaultEngine.ini (Ln58)
This didnt work.这没有用。 Trace cant find the object.
Trace 找不到 object。 hit value is false:
命中值为假:
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypesArray;
ObjectTypesArray.Reserve(1);
ObjectTypesArray.Emplace(ECollisionChannel::ECC_GameTraceChannel1);
bool hit = UKismetSystemLibrary::SphereTraceSingleForObjects(GetWorld(), StartLocation, EndLocation, 500.f, ObjectTypesArray, false,
IgnoredActors, EDrawDebugTrace::ForDuration, OutHit, true);
And this causes intellysense error: (No instance of overloaded function matches the argument list)这会导致智能感知错误:(没有重载 function 的实例与参数列表匹配)
ObjectTypesArray.Add(ECollisionChannel::ECC_GameTraceChannel1);
What should i do?我应该怎么办? How can i add my own object channel to my TArray?
如何将我自己的 object 通道添加到我的 TArray? Thanks a lot in advance.
提前非常感谢。
The value you need to add to the array is您需要添加到数组的值是
UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_GameTraceChannel1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.