using UnityEngine;
public class MotherBoardPlace : MonoBehaviour
{
Collision collision;
private void OnCollisionEnter(Collision collision)
{
this.collision = collision;
switch(collision.collider.tag)
{
case "Processor":
Place("ProcessorPlace", Vector3.zero);
break;
case "ram":
Place("RamPlace", new Vector3(0, 0, 90));
break;
case "CpuFan":
Place("CpuFanPlace", new Vector3(0, 0, 90));
break;
}
}
private void Place(string PlaceName, Vector3 Angle)
{
collision.rigidbody.isKinematic = true;
collision.rigidbody.detectCollisions = false;
collision.rigidbody.useGravity = false;
collision.transform.parent = transform.Find(PlaceName);
collision.transform.localPosition = Vector3.zero;
collision.transform.localEulerAngles = Vector3.zero + Angle;
if (!Grabbing.GrabObj.collider.CompareTag("Motherboard"))
{
Grabbing.grab = false;
}
}
}
using UnityEngine;
public class Place : MonoBehaviour
{
Collision collision;
private void OnCollisionEnter(Collision collision)
{
this.collision = collision;
switch(collision.collider.tag)
{
case "Motherboard":
place("MotherboardPlace", Vector3.zero);
break;
case "Power":
place("PowerPlace", Vector3.zero);
break;
case "Hdd":
place("HddPlace", Vector3.zero);
break;
case "Ssd":
place("SsdPlace", Vector3.zero);
break;
case "PcDoor":
place("PcDoorPlace", Vector3.zero);
break;
}
}
private void place(string PlaceName, Vector3 Angle)
{
collision.rigidbody.isKinematic = true;
collision.rigidbody.detectCollisions = false;
collision.rigidbody.useGravity = false;
collision.transform.parent = transform.Find(PlaceName);
collision.transform.localPosition = Vector3.zero;
collision.transform.localEulerAngles = Vector3.zero + Angle;
}
}