Is there any way I can make a (for example) Box Collider attached to a gameObject move seperately from the gameObject itself? So when I press W the Box Collider moves, not the gameObject itself.
I tried the following, but it moves the whole gameObject including the Box Collider:
void Update()
{
if (Input.GetKeyDown("w"))
{
this.gameObject.collider.transform.position = this.gameObject.collider.transform.position + new Vector3(0, 0, 0.32f);
}
}
You can add a collider to a child object of your gameobject and then move this child object. It’s more comfortable, than moving a center of the collider.