- Home /
Other
How do a swap the model of something at a certain distance?
I am new to Unity and Scripting and I have no idea how to do this. I want a gameobject to swap with another lower poly gameobject by turning one gameobject active off and turning the lower poly one on at a certain distance.
here is my plan:
var Building1 : GameObject var Building2 : GameObject var Camera : Camera
If camera distance > 500 then building1 = not active building2 = active
if camera distance < 500 then building1 = active building2 = not active
Thanks!
Your plan is fine. You need to spend some time studying up on the the syntax of Javascript. A few points that you might find helpful:
You can enable and disable a game object with GameObject.SetActive().
Vector3.Distance() is a way to find the distance between two points
Comparison uses '=='
You can access the main camera with 'Camera.main'
The transform.position of objects gives their position
You'll likely want to execute this code in Update()
Please try to solve this yourself. If you get stuck, post back with a new question.
Are you using pro? I know that comes with it. If you aren't I'm sure there is a workaround, I just don't know how effective it will be.
I am using free. I'm 16 and I don't have $1,500 laying around. :D