Anyone have any ideas on this, i dont mean like hit it and stop all forward motion, like go into it and stay if object moves then the arrow moves.
Stop physics and child it to the object. I’ve gotten some odd angles, but might work better now that OnColEnter happens before physics has its way. Could also back it up and ray cast:
OnCollisionEnter(Collision Col) {
rigidbody.isKenimatic=true; // stop physics
transform.parent = Col.transform; // doesn't move yet, but will move w/what it hit
What I did: (Works excellent) put this in your class
bool hit = false;
float depth = 0.30F;
void OnCollisionEnter2D(Collision2D other){
if (!hit) {
ArrowStick (other);
hit = true;
}
}
void ArrowStick(Collision2D col)
{
// move the arrow deep inside the enemy or whatever it sticks to
col.transform.Translate(depth * -Vector2.right);
// Make the arrow a child of the thing it's stuck to
transform.parent = col.transform;
//Destroy the arrow's rigidbody2D and collider2D
Destroy (gameObject.rigidbody2D);
Destroy (gameObject.collider2D);
}
Use a trigger collider on the arrow and then with some simple script using the OnTriggerEnter function, make it so the rigidbody is disabled as well as the collider and make the arrow a child of the object unless the object is tagged as static in which case the parenting is unnecessary.