- Home /
How to change the BoxCollider 2D Xoffset and Y offset by script ?
Hello,
Please someone knows how to change the BoxCollider 2D X,Yoffset in the script, because in my game when i jump i need to change the position of the colldier.
Thanks.
Comment
Best Answer
Answer by rlo · Nov 05, 2015 at 08:41 AM
gameObject.GetComponent<BoxCollider2D>().offset = new Vector2(newX, newY);
Answer by GiyomuGames · Nov 05, 2015 at 05:44 AM
You just need to modify this: http://docs.unity3d.com/ScriptReference/Collider2D-offset.html.
Your answer
Follow this Question
Related Questions
Translate Jump Trigger Collision Issue 1 Answer
Objects not jumpable on 2 Answers
Problems with raycast accuracy 1 Answer
Making a bullet invinceble 0 Answers
Script not recognizing collision 3 Answers