Here’s my problem im currentely spawning ennemies which are in a prefab in my scene…
I can spawn them, everything works but somehow they spawn in the air which isn t realistic…(Not that a spawning system is realistic but yeah )
What i’d like them to do is just spawn on the ground and not falling from the sky to the ground … Is that possible ? Do i have to use something else then Instantiate?
Please add your spawn code to your question so someone can give you an accurate answer. Also you need to define the type of ground you are using...plane, mesh, terrain...
Why not just add max gravity to the mobs and it should fall immediately, really fast possibly beyond perception? otherwise I was gonna say edit your spawn script to the coordinate above ground. I think gravity is a better idea, as long as your monters aren't sliding around you will be able to spawn monsters on hills, in water wherever you please because it's rigidbody should detect ground, but if you place the spawn at Y then it will always spawn at that height which, at x1,z1 ground could be 100y and at x2,z2 ground could be 2y if you follow
You have to check if your object is not inside a collider, otherwise it will flip out and thus causing to spawn in the air. Second thing you might wanna do is create a script for the prefab that checks the distance from the ground on start up (start function), you can do this with a raycast. Then check if the distance is to far, position it to the hit.position (Y?). This way your objects will get snapped to the ground on first frame of spawn. this should roughly work, but just as robertbu said, without an example code it is all guessing.
Thanks problem solved , you position gave me an idea of what could be wrong , it was the actually spawn coordinate that somehow changed so i just replced a little line spawnLoc.transform.position.y + Random.Range (spawn, spawn) FOR spawnLoc.transform.position.y + Random.Range (0, 0)
Please add your spawn code to your question so someone can give you an accurate answer. Also you need to define the type of ground you are using...plane, mesh, terrain...
– robertbuWhy not just add max gravity to the mobs and it should fall immediately, really fast possibly beyond perception? otherwise I was gonna say edit your spawn script to the coordinate above ground. I think gravity is a better idea, as long as your monters aren't sliding around you will be able to spawn monsters on hills, in water wherever you please because it's rigidbody should detect ground, but if you place the spawn at Y then it will always spawn at that height which, at x1,z1 ground could be 100y and at x2,z2 ground could be 2y if you follow
– KuPAfoo