Hello everybody ,
I want create a script for a nails Gun who can stick a wood board to a window or a door .
I use an Htc vive controller .
here is the script i use but if the board touch the door it stick directly without the nailgun .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class nailstick : MonoBehaviour {
public Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void EnableRagdoll()
{
rb.isKinematic = false;
rb.detectCollisions = true;
}
void DisableRagdoll()
{
rb.isKinematic = true;
rb.detectCollisions = false;
}
void OnCollisionEnter(Collision collision)
{
foreach (ContactPoint contact in collision.contacts)
{
if (collision.gameObject.tag == "contour")
{
DisableRagdoll();
collision.transform.parent = transform;
collision.collider.gameObject.transform.position = transform.position;
}
}
}
}
can you help me please ?
Thanks a lot by advance and sorry for my bad english i’m french .