Question by
roody11 · Apr 12, 2019 at 06:19 PM ·
scripting problemscipting
I have as background a picture unity 3d but i want to put it so the player can never reach it ?
I used this script. but as the 3d game begin after some minut i cant see the background annymore i want to put it so the player can never reach it**
.** public Transform SkyPrefabBackground; public Transform Player; public Vector3 vector3;
void FixedUpdate()
{
gameObject.SetActive(true);
Vector3 position = transform.position;
position.z = Player.transform.position.z + 289;
transform.position = position;
}
}
Comment
@$$anonymous$$RRAXE Have you thought about this; ins$$anonymous$$d of moving your background so your player can't reach it, putting a collider in front of it so your player can't go x amount near it? Just a thought...
Best Answer
Answer by Vollmondum · Apr 13, 2019 at 05:24 AM
public float distanceToSky;
public float skyMax;
if(sky.position.z > skyMax)
{
sky.position.z = player.position.z + distanceToSky;
skyMax = sky.position.z;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612195344im_/https://answers.unity.com/themes/thub/images/avi.jpg)