커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
Ramdom.Range(0f, 7f)인데 왜 정수로 나오나요?
undefined주차
북마크
김*현
댓글
8
추천
0
조회수
16
조회수
16
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


4-6 5분 정도부터 시작입니다

Ramdom.Range(0f, 7f)인데 왜 정수로 나오나요?

왜 값은 정수로 나오나요?


int arr이라 그런가요?

그럼 1이 두 번이 아니라 여러 번 나올 수도 있지 않나요?







작성한 코드 및 에러 메세지

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;


public class Board : MonoBehaviour
{


    public GameObject card;


    // Start is called before the first frame update
    void Start()
    {
        int[] arr = {0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7};
        arr= arr.OrderBy(x => Random.Range(0f, 7f)).ToArray();



        for(int i = 0; i<16; i++) {
        GameObject go = Instantiate(card, this.transform);


        float x = (i % 4) * 1.4f - 2.1f;
        float y = (i/4) * 1.4f - 3f;


        go.transform.position = new Vector2(x,y);
        }
    }


    // Update is called once per frame
    void Update()
    {
        
    }



}



취소
 공유
취소
댓글 0
댓글 알림
나의얼굴