当前位置: 代码网 > it编程>编程语言>Javascript > UE4随机数

UE4随机数

2024年08月01日 Javascript 我要评论
产生一个在X正半轴、Y正半轴、Z正半轴的任意一个位置。

1.函数:fmath::frand()

float x = fmath::frand();//产生一个 0.0 ~ 1.0之间的小数
void arandactor::beginplay()
{
	super::beginplay();

	float x = fmath::frand();
	float y = fmath::frand();
	float z = fmath::frand();

	initlocation.x = x;
	initlocation.y = y;
	initlocation.z = z;

	initlocation *= 500.0;

	if (binitlocation){
		setactorlocation(initlocation);
	}
}

产生一个在x正半轴、y正半轴、z正半轴的任意一个位置。

2.函数 fmath::frandrange(a, b)

float x = fmath::frandrange(-500, 500);//随机产生一个-500 ~ 500之间的一个数
void arandactor::beginplay()
{
	super::beginplay();

	float x = fmath::frandrange(-500, 500);
	float y = fmath::frandrange(-500, 500);
	float z = fmath::frandrange(0, 500);

	initlocation.x = x;
	initlocation.y = y;
	initlocation.z = z;
	if (binitlocation){
		setactorlocation(initlocation);
	}
}

aaa

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com