helloHello,
I want to scale a Game object based on how far away on how close the player is.
Note This is eventually for VR. I have a Game Object thats a small room and as you get closer it scales to be larger & visVersa.
What am I doing wrong?
public class scalePlayer : MonoBehaviour
{
public GameObject room;
public Transform center;
public float oldDist;
void Awake()
{
//Determine the Starting Distance between player and center of room to be scaled
float oldDist = Vector3.Distance(center.position, transform.position);
}
void Update()
{
//Determine the New distance between player and center of room to be scaled
float newDist = Vector3.Distance(center.position, transform.position);
room.transform.localScale = room.transform.localScale * (oldDist - newDist) * Time.deltaTime;;
}
}
There has to be an elegant way to do this
The scale of the room just goes down to Zero
Any ideas?
Thanks!
~be