- Introduce `0.unity` recovery scene for testing and backup purposes. - Add `Pump` GameObject with components including Rigidbody, CapsuleCollider, and MeshRenderer for physics interactions. - Add `Upper` GameObject with a Transform component for hierarchical relationships. - Configure physics parameters such as damping, constraints, and Rigidbody properties. - Update object layers, tags, and rendering configurations for improved scene setup.
34 lines
722 B
C#
34 lines
722 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class BottomPump : MonoBehaviour
|
|
{
|
|
public bool Grounded { get; private set; }
|
|
|
|
[SerializeField]
|
|
private LayerMask layerMask;
|
|
|
|
public Action<bool> GroundedChanged;
|
|
|
|
private void Start()
|
|
{
|
|
GroundedChanged?.Invoke(GetGroundedState());
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
var groundedNow = GetGroundedState();
|
|
|
|
if (groundedNow == Grounded) return;
|
|
|
|
Grounded = groundedNow;
|
|
GroundedChanged?.Invoke(Grounded);
|
|
}
|
|
|
|
private bool GetGroundedState()
|
|
{
|
|
const float distance = .35f;
|
|
|
|
return Physics.Raycast(transform.position, -transform.up, distance, layerMask);
|
|
}
|
|
} |