#wait why do i have to subtract number of

1 messages · Page 1 of 1 (latest)

remote temple
#

Am I correct in this, you are trying to

  1. Pick a random location
  2. Stack a bunch of papers starting from that location
  3. Make sure that stack doesnt go above a certain height
remote temple
#

Oh wait nevermind, I think I misread

dreamy basin
#

im picking a bunch of random locations, spawing a bunch of papers on thoose locations and make sure that none of the papers spawn on a very high y location

remote temple
#

Your randomPosition is hardlocking the y value to 0 already?

dreamy basin
#

no

#

its not

remote temple
#

randomPosition = new Vector3(Random.Range(125, 900), 0, Random.Range(150, 850));

dreamy basin
#

yeah but that 0 is a fill in

#

the hit.y pos

remote temple
#

oh ok I see I sees

dreamy basin
#
        {
            Vector3 randomPosition = new Vector3(Random.Range(125, 900), 0, Random.Range(150, 850));
            NavMeshHit hit;
            if (NavMesh.SamplePosition(randomPosition, out hit, 50f, NavMesh.AllAreas))
            {
                Instantiate(paper, new Vector3(hit.position.x, hit.position.y + 1, hit.position.z), Quaternion.identity);
            }
        } 
#

hit.position.y

remote temple
#

So if it is too high you just dont want it to spawn at all

#

Or do you want some logic to try again?

dreamy basin
remote temple
#

ok one sec

dreamy basin
#

because it needs to spawn

remote temple
#
        for(int i = 0; i < int.Parse(amountOfPapers.text); i++)
        {
            while(true){
                Vector3 randomPosition = new Vector3(Random.Range(125, 900), 0, Random.Range(150, 850));
                NavMeshHit hit;

                if (NavMesh.SamplePosition(randomPosition, out hit, 50f, NavMesh.AllAreas)){
                        if(hit.position.y < maxSpawnHeight){
                            Instantiate(paper, new Vector3(hit.position.x, hit.position.y + 1, hit.position.z), Quaternion.identity);
                            break;
                        }
                }
            }
        }
#

this is pretty ugly

#

But it should just attempt again and again until it finds one that is under your set height

dreamy basin
#

dont worry it will do thanks

remote temple
#

Try it and let me know if it works

dreamy basin
#

ill do that maybe in 2 hours

#

or 1

remote temple
#

Feel free to Dm if you want, I don't know how long threads last in this disc

dreamy basin
#

okay thanks (you can always revive threads)

remote temple
#

I also may not see it 😂 I have pretty much everything but DM muted

dreamy basin
#

okay

#

doing some ai battle royale

remote temple
#

Very neat haha funny concept

dreamy basin
#

The idea isnt really mine, i was talking with my friend denis(the guy that made EarthX) and yeah

dreamy basin
#

@remote temple Fu*k this wont work

#

i think ill do like a couple of colliders where the bots cant spawn and if they spawn in there then yeah

#

hmmmm this also wont work

#

well i did something stupid but it works!