forked from nope5166/AtomCraft-2.28
38 lines
735 B
C#
38 lines
735 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class GrabbableObject : MonoBehaviour
|
|
{
|
|
private AudioSource audioSource;
|
|
private Rigidbody rb;
|
|
|
|
void Start()
|
|
{
|
|
// Get the AudioSource component
|
|
audioSource = GetComponent<AudioSource>();
|
|
|
|
// Get the Rigidbody component
|
|
rb = GetComponent<Rigidbody>();
|
|
}
|
|
|
|
void OnMouseDown()
|
|
{
|
|
GrabObject();
|
|
}
|
|
|
|
void GrabObject()
|
|
{
|
|
// Play sound clip
|
|
if (audioSource != null)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
|
|
// Perform grab logic here
|
|
// For example, disable physics to hold the object in place
|
|
rb.isKinematic = true;
|
|
}
|
|
}
|
|
|