- Home /
Spawning player at appropriate point in random model of a city using only the mesh data.
I have a random .obj model of a city of random size and I want to spawn my character in an appropriate place which should basically be at a lower height and should be a flat part of the city without any obstructions around it. How can I identify what points in the model are good for spawning using only the mesh of the model ?
Answer by DanielGL · Jan 15, 2021 at 06:51 PM
I don't know if it's the best way, but one solution is: 1-Create a spawn area; 2-Cast multiple ray casts in direction of the ground; 3-Spawns the player in the most low Y collision;
You can also make use of layer masks to make the raycast only detect valid surfaces to your player spawns!
Yes, a good idea would be to mark an area that is flat and generally a good spawn point with a tag or layer. Then spawn an object at a high y position, fire a raycast, and keep lowering the object till the raycast length is quite low.
Your answer
Follow this Question
Related Questions
ai spawning please help 0 Answers
Random spawnpoint where only one prefab can spawn! 1 Answer
How to spawn objects using an array of spawn points w/o intersecting 1 Answer
How to spawn enemies on my spawnpoints 1 Answer
Spawn Point 2 Answers