mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-22 15:18:25 -05:00
31 lines
818 B
C#
31 lines
818 B
C#
using System;
|
|
using UnityAtoms.BaseAtoms;
|
|
using UnityEngine;
|
|
|
|
namespace GolfControls
|
|
{
|
|
public class BallPhysics : MonoBehaviour
|
|
{
|
|
private float baseDrag;
|
|
private float baseAngularDrag;
|
|
|
|
private Rigidbody body;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
body = gameObject.GetComponent<Rigidbody>();
|
|
baseDrag = body.drag;
|
|
baseAngularDrag = body.angularDrag;
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision other)
|
|
{
|
|
PhysicsTerrain terrain = other.gameObject.GetComponent<PhysicsTerrain>();
|
|
if (terrain == null) return;
|
|
body.drag = baseDrag + terrain.drag;
|
|
body.angularDrag = baseAngularDrag + terrain.angularDrag;
|
|
}
|
|
}
|
|
}
|