Stick a projectile to an object (arrow into an object)

So I am trying to stick an arrow into the object that the arrow collides with so, I am using OnCollisionEnter like so, where the script is attached to the arrow with a collider at the tip of the arrow:

private void OnCollisionEnter(Collision collision)
        if (collision.collider.tag != "Player")
            rb.isKinematic = true;
            transform.parent = collision.gameObject.transform;

But that is creating some issues. Like when you parent the arrow to the object the scaling of the object is applied to the arrow. So if the object is scaled on the X by 10, the arrow will be scaled on the X by 10.

So, to solve that, I tried to re-scale the arrow after making it the child of the object with:

            transform.localScale = new Vector3(transform.localScale.x / collision.transform.lossyScale.x, transform.localScale.y / collision.transform.lossyScale.y, transform.localScale.z / collision.transform.lossyScale.z);

But that didn’t seem to do the trick. Anyone have any suggestions for alternatives or tweaks?



For the solving parenting scale problem you can use third gameobject. Because localScale gets first parents scaling, so we need new game object with 1,1,1 scaling in the middle (of hierarchy) of two attaching objects. It is common problem with making as a child game object without a scaling. So there is just few lines of code that will solve this:

    private void OnCollisionEnter(Collision collision)
        if (collision.collider.tag == "Player")
            // greating Parent's child let's name him Father :D
            GameObject sharedParent = new GameObject("Father");
            sharedParent.transform.position = collision.transform.position;
            sharedParent.transform.rotation = collision.transform.rotation;

            // making child and grandpa as a kinematic
            collision.gameObject.transform.GetComponent<Rigidbody>().isKinematic = true;
            gameObject.GetComponent<Rigidbody>().isKinematic = true;

            // assigning relatives
            sharedParent.transform.parent = collision.gameObject.transform; 
            transform.parent = sharedParent.transform;

you can set a bool variable on the arrow and put a trigger on its top so when it hits something this bool is activated and it stops the movement