鱼C论坛

 找回密码
 立即注册
查看: 842|回复: 3

unity c#脚本中无法使用随机数

[复制链接]
发表于 2024-7-23 13:44:25 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
这是在unity中打开的脚本,但是他提示
            if (Randow.Range(0f, 1f) > 0.5f)
这一句的
error CS0103: The name 'Randow' does not exist in the current context
这是为什么??

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;

  4. public class enemyCreat : MonoBehaviour
  5. {
  6.     public GameObject enemyToCreat;

  7.     public float timeToCreat;
  8.     private float creatNumb;

  9.     public Transform minCreat, maxCreat;
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.         creatNumb = timeToCreat;
  14.     }

  15.     // Update is called once per frame
  16.     void Update()
  17.     {
  18.         creatNumb -= Time.deltaTime;
  19.         if (creatNumb <= 0)
  20.         {
  21.             creatNumb = timeToCreat;
  22.             //Instantiate(enemyToCreat, transform.position, transform.rotation);
  23.             Instantiate(enemyToCreat, SelectCreatPoint(), transform.rotation);
  24.         }
  25.     }
  26.     public Vector3 SelectCreatPoint()
  27.     {
  28.         Vector3 creatPoint = Vector3.zero;
  29.         bool creatVerticalEdge = Randow.Range(0f, 1f) > 0.5f;

  30.         if (creatVerticalEdge)
  31.         {
  32.             creatPoint.y = Randow.Range(minCreat.position.y, maxCreat.position.y);
  33.             if (Randow.Range(0f, 1f) > 0.5f)
  34.             {
  35.                 creatPoint.x = maxCreat.position.x;

  36.             }
  37.             else
  38.             {
  39.                 creatPoint.x = minCreat.position.x;

  40.             }
  41.         }
  42.         else
  43.         {
  44.             creatPoint.x = UnityEngine.Randow.Range(minCreat.position.x, maxCreat.position.x);
  45.             if (Randow.Range(0f, 1f) > 0.5f)
  46.             {
  47.                 creatPoint.y = maxCreat.position.y;

  48.             }
  49.             else
  50.             {
  51.                 creatPoint.y = minCreat.position.y;

  52.             }
  53.         }
  54.         return creatPoint;
  55.     }
  56. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2024-7-23 13:54:15 | 显示全部楼层
好了,此贴完结,纯粹是写错了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-7-23 13:46:51 | 显示全部楼层
@FishC
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-7-23 21:53:49 | 显示全部楼层
跟我之前一样
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-19 23:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表