How to shrink the player AND the charachter controller component radius.
I am about half a year new to unity and am starting to grasp the basics of coding. Using the standard fps prefab I created a simple script where the prefab will shrink and grow when I click the mouse, but the green capsule wireframe of the character controller does not change with it and collides with other objects as if it were normally sized. Pls Help. Much thanks.
public class scale : MonoBehaviour {
void Update()
{
if (Input.GetMouseButtonDown(0))
{
transform.localScale += new Vector3(-5.1F, -5, -5);
}
if (Input.GetMouseButtonDown(1))
{
transform.localScale += new Vector3(5.1F, 5, 5);
}
}
}
Comment
Answer by BloodMarked · Apr 23, 2017 at 09:04 PM
you need to get the capule collider and store it in a variable:
CapsuleCollider cc =GetComponent()
then scale its size properties too:
cc.height *= 5;
cc.radius *= 5;
you propably have to scale cc.center too
etc. i have not tested it, but this is basically how you do it