Files
pogo-stick-game/Assets/BottomPump.cs
ondroftw 2c21749c21 Add recovery scene and Pump/Upper objects with physics configurations
- 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.
2025-10-26 13:23:46 +01:00

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);
}
}