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.
 
 
 
 

74 lines
1.8 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 bool m_RampActive;
public float m_RampTimer;
public float m_RampIncrement;
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)
{
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);
if (!m_RampActive && m_RampTimer > 0f)
{
m_RampTimer -= Time.deltaTime;
}
else
{
m_RampActive = true;
}
if( m_RampActive )
{
m_MaxForce += Time.deltaTime * m_RampIncrement;
}
Debug.Log($"Treadmill Speed: {m_MaxForce}");
}
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);
}
}