Need Help for NailGun script

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 .

What is this nailstick script on? The woodboard?

I don’t see anywhere where you use a nail gun, or require it use.

Translation :

Ton nailstick script il est sur quel object? Il semble être sur la planche?

Je vois pas nul part que tu utilise ou vérifie si le nailgun est utilisé.

Hi , i put this script on the board :wink: and another to the bullet of the nailgun .
that’s stick it together but it doesn’t work like i want :frowning:

Maybe change it to on collision stay and then add a nailgunFire bool