Right click hammer time!

This commit is contained in:
nothke
2024-08-20 00:20:33 +02:00
parent 71f05400e4
commit 965e207eb4
5 changed files with 49 additions and 15 deletions

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Nothke.Interaction;
using Nothke.Interaction.Items;
public class Hammer : GenericItem
{
private void Update()
{
if (manager && manager.hands.item == this)
{
if (Input.GetMouseButtonDown(1))
{
if (manager.hovered is HammerableRigidbody hammerable)
{
hammerable.Hammer();
var hands = (manager.hands as Hands);
var hand = hands.hand;
hand.transform.position = manager.hit.point;
hand.transform.localPosition += new Vector3(0f, -0.4f, 0f); // Offset to match the hammer head
hands.ResetOffset();
}
}
}
}
}