最初はオブジェクトの影だけが表示され、ジャンプするとすぐにオブジェクトが表示されるゲームを作ろうとしています。誰もそれを行う方法を知っていますか?
ゲームのスクリーンショット:

プレーヤーに「プレーヤー」タグを追加します。オブジェクトのコードは、おそらく次のようになります。
// SerializeField means that the variable will show up in the inspector
private MeshRenderer renderer; // The Mesh Renderer is the component that makes objects visible
private void Start()
{
renderer = GetComponent<MeshRenderer>(); // Get the Mesh Renderer that is attached to this GameObject
renderer.enabled = false; // Disable the renderer so that it is invisisble
}
private void OnCollisionEnter(Collision other) // When the object collides with something
{
if (other.gameObject.CompareTag("Player")) // See if the GameObject that we collided with has the tag "Player"
{
renderer.enabled = true; // Enable the renderer, making the GameObject invisible
}
}
または:
private MeshRenderer renderer; // The Mesh Renderer is the component that makes objects visible
[SerializeField] Material invisibleMaterial; // A invisible material
[SerializeField] Material defaultMaterial; // The default, visible material
private void Start()
{
renderer = GetComponent<MeshRenderer>(); // Get the Mesh Renderer that is attached to this GameObject
renderer.material = invisibleMaterial; // Sets the material of the object to the invisible on, rendering it invisible
}
private void OnCollisionEnter(Collision other) // When the object collides with something
{
if (other.gameObject.CompareTag("Player")) // See if the GameObject that we collided with has the tag "Player"
{
renderer.material = defaultMaterial; // Sets the material to the default material
}
}