- Home /
Question by
DiamondMC102 · Sep 12, 2017 at 01:33 AM ·
collider2d game2d-platformerboxcollider2d
How can I move my BoxCollider2D ?
How can I move my BoxCollider2D that is attached to my Player in c#.
Comment
Can you elaborate? What are you trying to achieve exactly?
Best Answer
Answer by tmalhassan · Sep 12, 2017 at 01:48 AM
I don't really understand what you want to do, as you need to explain more. But i will assume that you want to move only the collider, but not the object. If that is the case, you can simply do it by changing the offset of the collider. Try this:
gameObject.GetComponent<BoxCollider2D>().offset = new Vector2(newX, newY);
Maybe i can help more if you can explain better.
All the best.
@tmalhassan What you assumed is what I needed help with. Thank you a bunch.
Your answer
Follow this Question
Related Questions
How to check if BoxCollider2D collided with another BoxCollider2D? 2 Answers
platform 2d about collider 3 Answers
Unity 2D platformer collider 1 Answer
2D collider troubles 1 Answer