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
发表评论