[yes / no question] Move objects WITH the terrain
Hello, dear community!
I would like to ask a question, hopefully someone will answer. I had a flat terrain. I added some objects onto it. Then I decided to rise some parts of the terrain and make those objects standing on the hill. The hill was created, but the objects remained at their previous position.
The question: is it possible to move objects ON the terrain, somehow "clip them to it", so that if I decide to move terrain UP or DOWN - the objects will move respectfully UP or DOWN too?
Thanks!
Answer by Dave-Carlile · Oct 07, 2015 at 07:41 PM
Yes, it is.
thank you for a prompt answer! Do you know how? By code or is there any option in the editor?
But... but... you said it was a yes/no question! :p
I believe this is something you'd need to do in code. You can add a script to your object that samples the terrain height at the object's position, then set it's y coordinate to move it up.
You can have the script execute in edit mode if you want it to move around as you alter the terrain. Sometimes there are gotchas with that - you'd have to do it and see. Otherwise if you call the code in Start your objects can move to the proper height when the game starts.
I did - I accepted your answer :) Thank you again. And thank you very much (especially for the link) :)
Your answer
Follow this Question
Related Questions
Positioning / Distributing Prefabs in an environment 0 Answers
How to fix position of objects? 0 Answers
Lighting issues at Runtime. Trees and other objects glow in the dark. 0 Answers
How to make multiple objects with the same script work independently? 0 Answers
How can i make an object (a cube) change the surface or plan of the game? 2 Answers