You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SiegeSong;
namespace SiegeSong
{
public class Foot : MonoBehaviour
{
public bool Grounded;
public bool Unstable;
public ActorPhysicsManager PhysicsManager;
void OnCollisionEnter(Collision collision)
{
var isUnstable = true;
if (collision.transform.gameObject.CompareTag("Water"))
{
Unstable = false;
Grounded = false;
}
if (collision.transform.gameObject.CompareTag("Terrain"))
{
Unstable = false;
Grounded = true;
}
if (collision.transform.gameObject.CompareTag("Floor"))
{
Unstable = false;
Grounded = true;
}
Unstable = isUnstable;
var ramp = collision.gameObject.GetComponent<Ramp>();
if (ramp != null)
{
PhysicsManager.ActorMotor.FeetCollidingWithRamp = true;
PhysicsManager.ActorMotor.RampAngle = ramp.Angle;
PhysicsManager.ActorMotor.RampMagnitude = ramp.Magnitude;
//Vector3.Distance(transform.position, ramp.StartPoint.position)
//Vector3.Distance(transform.StartPoint.position, ramp.EndPoint.position)
//Vector3.Distance(transform.position, ramp.EndPoint.position)
}
}
void OnCollisionExit(Collision collision)
{
Unstable = false;
if (collision.transform.gameObject.CompareTag("Water"))
{
Grounded = true;
}
if (collision.transform.gameObject.CompareTag("Terrain"))
{
Grounded = false;
}
if (collision.transform.gameObject.CompareTag("Floor"))
{
Grounded = false;
}
if (collision.gameObject.GetComponent<Ramp>() != null)
{
PhysicsManager.ActorMotor.FeetCollidingWithRamp = false;
}
}
void Start()
{
}
void Update()
{
}
}
}