projection test for gallery space w/ chair using squeezed & gnomic projection.
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.

53 lines
1.5 KiB

using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices.WindowsRuntime;
using Unity.VisualScripting;
using UnityEngine;
public class Treadmill : MonoBehaviour
{
//public Rigidbody m_Body;
public float m_MaxForce;
private float m_angleOffset;
private void OnEnable()
{
OnChairContact.ApplyTreadmillForce += ApplyForce;
OnChairContact.RemoveTreadmillForce += RemoveForce;
m_angleOffset = 20f;
}
private void OnDisable()
{
OnChairContact.ApplyTreadmillForce -= ApplyForce;
OnChairContact.RemoveTreadmillForce -= RemoveForce;
}
public void ApplyForce(Rigidbody rb)
{
//m_Force += 0.1f;
Vector3 forceDirection = Quaternion.Euler(0, -m_angleOffset, 0) * Vector3.forward;
//Debug.Log($"Force added to {rb.name} {forceDirection * m_MaxForce}");
rb.AddForce(forceDirection * m_MaxForce);
//m_Body.AddForce(forceDirection * m_Force);
}
public void RemoveForce(Rigidbody rb)
{
rb.AddForce(new Vector3(0, 0, 0));
}
private void FixedUpdate()
{
//Debug.Log($"Applying Force {m_Force}");
//m_Force = (m_Force < 0f) ? 0 : (m_Force > m_MaxForce) ? m_MaxForce : m_Force;
}
private void OnDrawGizmosSelected()
{
// Draw a line representing the force direction
Gizmos.color = Color.red;
Gizmos.DrawRay(transform.position, Quaternion.Euler(0, -m_angleOffset, 0) * Vector3.forward);
}
}