SebLague / Solar-System

Simple solar system experiment
https://www.youtube.com/watch?v=7axImc1sxa0
MIT License
1.15k stars 315 forks source link

How do I make buildings in my project? #29

Closed WilleD70 closed 3 years ago

Delofon commented 3 years ago

Please, can you be more specific about "buildings"?

WilleD70 commented 3 years ago

Please, can you be more specific about "buildings"?

Hello! By building I mean building 3d models that stick to the planet. It would help if you could delete terrain, but keep atmosphere.

Delofon commented 3 years ago

This is possible through raycast - in PlayerController class, you test for whatever button you want pressed. If that button is pressed, shoot a ray of defined length. If the ray hit an object of type CelestialBody, spawn a prefab "building" with the 3d model you want at a position of ray hit rotated according to the hit normal parented to the CelestialBody object. Additionally, you may check if the hit CelestialBody BodyType is not Sun before spawning prefab. Hope this helps.

WilleD70 commented 3 years ago

This is possible through raycast - in PlayerController class, you test for whatever button you want pressed. If that button is pressed, shoot a ray of defined length. If the ray hit an object of type CelestialBody, spawn a prefab "building" with the 3d model you want at a position of ray hit rotated according to the hit normal parented to the CelestialBody object. Additionally, you may check if the hit CelestialBody BodyType is not Sun before spawning prefab. Hope this helps.

Hello! I've tried but I don't seem to get it right. If you wouldn't mind, could you make a video where you do it or something. All the best!

WilleD70 commented 3 years ago

Hello again. I found a way to place gameobjects on the planets.