#wait why do i have to subtract number of
1 messages · Page 1 of 1 (latest)
Am I correct in this, you are trying to
- Pick a random location
- Stack a bunch of papers starting from that location
- Make sure that stack doesnt go above a certain height
thats not it
Oh wait nevermind, I think I misread
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
Your randomPosition is hardlocking the y value to 0 already?
randomPosition = new Vector3(Random.Range(125, 900), 0, Random.Range(150, 850));
oh ok I see I sees
{
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
So if it is too high you just dont want it to spawn at all
Or do you want some logic to try again?
i want it to try to spawn somewhere else then
ok one sec
because it needs to spawn
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
dont worry it will do thanks
Try it and let me know if it works
Feel free to Dm if you want, I don't know how long threads last in this disc
okay thanks (you can always revive threads)
I also may not see it 😂 I have pretty much everything but DM muted
okay
if you would wanna check what i need it for is this: https://scinacz.itch.io/rock-paper-scissors-simulation
doing some ai battle royale
Very neat haha funny concept
The idea isnt really mine, i was talking with my friend denis(the guy that made EarthX) and yeah
ok im gonna try and adding this to the script lets see if it works (if it dosent i have an idea)
@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!