- Home /
Capsule Collider editing via script?
So, what I want to do is to add a script where you press (hold) the left control key, and the capsule collider on the player shrinks (the height shrinks), as well as the center of the capsule collider changes to a different y coordinate.
Answer by Pflobus · Jun 20, 2015 at 12:16 AM
I figured it out (this is my script, at least):
.
var capCol: CapsuleCollider;
capCol = gameObject.GetComponent("CapsuleCollider");
.
function Update () {
if (Input.GetButton("Crouch")) {
capCol.height = 0.9f;
capCol.center.y = 0.3f;
}
else {
capCol.height = 1.0f;
capCol.center.y = 0.28f;
}
}
Your answer
Follow this Question
Related Questions
How to change the BoxCollider 2D Xoffset and Y offset by script ? 2 Answers
Box and circle Collider doesn't work 1 Answer
Can you make a ball not hit other balls? (circle colliders) 1 Answer
WheelCollider - I don't have a circle of Collider 1 Answer
Physics.OverlapSphere not detecting Instantiated Objects 1 Answer