Doa'a Ghandour
Doa'a Ghandour

Reputation: 11

Stick gameObject after collision

I'm trying to develop a fishing game, I need to make the fish goes with the hook after they collide, I tried to do this by using this:

void OnCollisionEnter2D(Collision2D collision) { 
    if(collision.gameObject.tag == "Hook") {
        transform.parent = collision.transform;
    }
} 

But the fish keeps moving after the collision, however it goes up and down like the hook's movement. Can anyone help me, please?

Upvotes: 1

Views: 107

Answers (1)

Ming-Tang
Ming-Tang

Reputation: 17651

Try to disable the rigidbody of the fish, and/or set the fish to "kinematic" mode.

http://docs.unity3d.com/ScriptReference/Rigidbody.html : see isKinematic and detectCollisions.

Upvotes: 0

Related Questions