samedi 22 août 2020

As for a random position inside the area

How do I modify the code so that the character randomly changes position inside the green area when the game starts? I don't know how to find the minimum and maximum values of the X and Z coordinates of this green area. Sorry for the bad English and thank you for the advice and help enter image description here

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class randomzombieposition : MonoBehaviour {
float x;
 float y;
 float z;
 Vector3 pos;  
    // Use this for initialization
    void Start () {  
  x = Random.Range(17,18);
     y = 0;
     z = Random.Range(25,46);
     pos = new Vector3(x, y, z);
     transform.position = pos;  
    }
    
    // Update is called once per frame
    void Update () {
    }
}



Aucun commentaire:

Enregistrer un commentaire