GetRandomReachablePointInRadius和GetRandomPointInNavigableRadius

本文介绍了UE4中两个用于生成随机位置的C++函数:K2_GetRandomReachablePointInRadius和K2_GetRandomLocationInNavigableRadius。前者确保返回的位置是可达的,而后者则可能返回不可达的导航点,特别是在存在障碍如孤立平台的情况下。选择使用哪个函数取决于是否需要保证路径可达性。
摘要由CSDN通过智能技术生成

蓝图节点

C++接口

	/** Generates a random location reachable from given Origin location.
	 *	@return Return Value represents if the call was successful */
	UFUNCTION(BlueprintPure, Category = "AI|Navigation", meta = (WorldContext = "WorldContextObject", DisplayName = "GetRandomReachablePointInRadius", ScriptName = "GetRandomReachablePointInRadius"))
	static bool K2_GetRandomReachablePointInRadius(UObject* WorldContextObject, const FVector& Origin, FVector& RandomLocation, float Radius, ANavigationData* NavData = NULL, TSubclassOf<UNavigationQueryFilter> FilterClass = NULL);

	/** Generates a random location in navigable space within given radius of Origin.
	 *	@return Return Value represents if the call was successful */
	UFUNCTION(BlueprintCallable, Category = "AI|Navigation", meta = (WorldContext = "WorldContextObject", DisplayName = "GetRandomLocationInNavigableRadius", ScriptName = "GetRandomLocationInNavigableRadius"))
	static bool K2_GetRandomLocationInNavigableRadius(UObject* WorldContextObject, const FVector& Origin, FVector& RandomLocation, float Radius, ANavigationData* NavData = NULL, TSubclassOf<UNavigationQueryFilter> FilterClass = NULL);

二者都是获取范围内一个随机位置,区别是

GetRandomReachablePointInRadius:一定可达。

GetRandomPointInNavigableRadius:不一定可达。例如在孤立平台上,随机到周围地面,实际上从当前位置到随机位置不可达。

参考

What's the difference between GetRandomReachablePointInRadius and GetRandomPointInNavigableRadius? In which case we should use which. - UE4 AnswerHub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值