Files
PrinceOfGlory/Packages/com.unity.xr.openxr/Samples~/MeshingFeature/FallingSphere.cs
2026-03-03 03:15:46 +08:00

35 lines
838 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEngine.XR.OpenXR.Samples.MeshingFeature
{
public class FallingSphere : MonoBehaviour
{
private Vector3 starting;
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
starting = transform.position;
}
// Update is called once per frame
void FixedUpdate()
{
if (transform.position.y < -10)
{
#if UNITY_6000_0_OR_NEWER
rb.linearVelocity = Vector3.zero;
#else
rb.velocity = Vector3.zero;
#endif
rb.angularVelocity = Vector3.zero;
rb.MovePosition(starting);
}
}
}
}