tnt graphics, bug fixes, folder organization

This commit is contained in:
2026-03-28 20:47:10 -05:00
parent 57b14d4ba9
commit 6491a3df11
45 changed files with 10533 additions and 148 deletions
+86
View File
@@ -0,0 +1,86 @@
using UnityEngine;
using UnityEngine.Rendering.Universal;
using static UnityEngine.GraphicsBuffer;
public class ThrowableHand : Tool
{
[Header("Throwable Hand Parameters")]
public float range;
public float forceModifier;
public float loft;
public GameObject testBomb;
// Mathematical plane used to catch the raycast from camera to get direction for
// looking at the mouse
private Plane handGroundPlane;
private DecalProjector targetProjection;
private float throwForce;
private void Update()
{
if (GameManager.Instance.GetPlayerController() != null)
{
SetGroundPlane();
DrawTargetProjection();
}
}
private void SetGroundPlane()
{
if (handGroundPlane == null)
{
handGroundPlane = new Plane(Vector3.up, -GameManager.Instance.GetPlayerController().DougBody.transform.position.y);
}
handGroundPlane.distance = -GameManager.Instance.GetPlayerController().DougBody.transform.position.y;
handGroundPlane.normal = Vector3.up;
}
private void DrawTargetProjection()
{
if (targetProjection == null)
{
targetProjection = GetComponentInChildren<DecalProjector>();
}
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (handGroundPlane.Raycast(ray, out var distance))
{
Vector3 hitPoint = ray.GetPoint(distance);
float distanceFromPoint = Vector3.Distance(hitPoint, transform.position);
if (distanceFromPoint > range)
{
Vector3 directionTowardMouse = (hitPoint - transform.position).normalized;
targetProjection.transform.position = new Vector3(transform.position.x, hitPoint.y, transform.position.z);
targetProjection.transform.position += directionTowardMouse * range;
throwForce = range;
}
else
{
targetProjection.gameObject.SetActive(true);
targetProjection.transform.position = hitPoint;
throwForce = distanceFromPoint;
}
}
}
public override void Use()
{
GameObject newBomb = Instantiate(testBomb);
newBomb.transform.position = transform.position;
Vector3 direction = transform.forward * throwForce * forceModifier;
direction += GameManager.Instance.GetPlayerController().GetVelocity();
direction.y = loft;
newBomb.GetComponent<Rigidbody>().AddForce(direction, ForceMode.Impulse);
}
public override void UseAlt()
{
throw new System.NotImplementedException();
}
}