- Home /
Problem with "sticking" to a block.
Basically I have a character, when it hits a block it sticks to it and gravity stops taking a hold. When it's pulled away it unsticks. This is handled with a basic onCollisionEnter and onCollisionExit (This script is attached to the character). It's all working fine. The problem arises when the block that it is stuck to is destroyed, sometimes this might happen because of a nearby explosion or something. onCollisionExit isn't called when it's destroyed so the character remains stuck in empty space. Does anyone have an idea how I might solve this?
EDIT: Sorted by constantly checking if it's still colliding with the block by recording the objects name when colliding with it and checking if the object still exists.
//try moving it off screen first and and destroy the block a second later
block.transform.position=new Vector3(0,-30,0);
Destroy(block,1);
Your answer
Follow this Question
Related Questions
Entering/exiting vehicles 1 Answer
Make an object stick to another once it collides with it in 2D 1 Answer
Problem Enter and Exit with Vehicle 2 Answers
JS Enter Exit with NetworkPlayer 1 Answer
jump on collision enter 1 Answer