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?