Quantcast
Channel: Questions in topic: "random spawn"
Viewing all articles
Browse latest Browse all 125

How to check collisions of static objects when spawned at Random?

$
0
0
Hi! For my project I am spawning static rooms at random. They should not be influenced by gravity, or move at all once they are placed for that matter. In the class room only the followingis relevant: void Start () { gameObject.AddComponent(); Rigidbody rb = gameObject.AddComponent(); rb.isKinematic = true; gameObject.transform.position = position; gameObject.transform.localScale = size; } And in my generator, I create a random room like this: IEnumerator FindRandomPos() { Room newRoom = CreateRoom(/*Random position*/); yield return null; Vector3 direction = randomUtility.RandomDirection(); while (newRoom.collides) { newRoom.Push(direction); yield return null; } yield return null; } As I understand collsions will not be detected in the frame the rooms get spawned, thats why I included the yields. Push() should simply move the rooms out of each others ways for now. The coroutine gets called in Update until my set roomlimit is reached. Now the big question: Why dont any collisions occur? The rooms spawn within eachother, in other (nonkinematic and kinematic) objects and Push never gets called. Thanks for your help!

Viewing all articles
Browse latest Browse all 125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>