unity c#脚本中无法使用随机数
这是在unity中打开的脚本,但是他提示if (Randow.Range(0f, 1f) > 0.5f)
这一句的
error CS0103: The name 'Randow' does not exist in the current context
这是为什么??
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyCreat : MonoBehaviour
{
public GameObject enemyToCreat;
public float timeToCreat;
private float creatNumb;
public Transform minCreat, maxCreat;
// Start is called before the first frame update
void Start()
{
creatNumb = timeToCreat;
}
// Update is called once per frame
void Update()
{
creatNumb -= Time.deltaTime;
if (creatNumb <= 0)
{
creatNumb = timeToCreat;
//Instantiate(enemyToCreat, transform.position, transform.rotation);
Instantiate(enemyToCreat, SelectCreatPoint(), transform.rotation);
}
}
public Vector3 SelectCreatPoint()
{
Vector3 creatPoint = Vector3.zero;
bool creatVerticalEdge = Randow.Range(0f, 1f) > 0.5f;
if (creatVerticalEdge)
{
creatPoint.y = Randow.Range(minCreat.position.y, maxCreat.position.y);
if (Randow.Range(0f, 1f) > 0.5f)
{
creatPoint.x = maxCreat.position.x;
}
else
{
creatPoint.x = minCreat.position.x;
}
}
else
{
creatPoint.x = UnityEngine.Randow.Range(minCreat.position.x, maxCreat.position.x);
if (Randow.Range(0f, 1f) > 0.5f)
{
creatPoint.y = maxCreat.position.y;
}
else
{
creatPoint.y = minCreat.position.y;
}
}
return creatPoint;
}
}
好了,此贴完结,纯粹是写错了 @FishC {:10_269:} {:10_257:}跟我之前一样
页:
[1]