- Home /
Question by
LockerAT · May 16, 2019 at 09:29 PM ·
colliderobjectcollider2dtransform.position
collider position wrong object position in collider
Hi guys. How to make correctly that the object in the collider follows its position after the moving collider? Because my object is moving in the center of the collider.
private void OnTriggerStay2D(Collider2D other)
{
other.transform.position += (transform.position - other.transform.position);
}
I tried this method, but there is a minus in it, the fact that the object moves to the child, which pulls out from the other parent.
private void OnTriggerStay2D(Collider2D other)
{
other.transform.parent = gameObject.transform;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612201545im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to fix box drop via code animation? 2 Answers
Using collider to gameobject detect attack or not 2 Answers
Object spins out of control 1 Answer
Hazards not Working Properly 1 Answer
Change both collider axis using Alt 1 Answer