You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
904 B
41 lines
904 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Treadmill : MonoBehaviour
|
|
{
|
|
public Rigidbody m_Body;
|
|
private float m_Force;
|
|
private float m_angleOffset;
|
|
|
|
private void OnEnable()
|
|
{
|
|
m_Force = 0f;
|
|
m_angleOffset = 20f;
|
|
}
|
|
|
|
public void ApplyForce()
|
|
{
|
|
// m_Force += 0.1f;
|
|
// float m_ClampedForce = Mathf.Clamp(m_Force, 0f, 100f);
|
|
m_Force += 0.2f;
|
|
Debug.Log($"Applying Force {m_Force}");
|
|
Vector3 forceDirection = Quaternion.Euler(0, -m_angleOffset, 0) * Vector3.back;
|
|
m_Body.AddForce(forceDirection * m_Force);
|
|
}
|
|
|
|
public void RemoveForce()
|
|
{
|
|
Debug.Log("Removing Treadmill Force");
|
|
m_Force = 0;
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
m_Force -= 0.05f;
|
|
if (m_Force < 0f)
|
|
{
|
|
m_Force = 0;
|
|
}
|
|
}
|
|
}
|
|
|