Weapon hit boxes

sneekyo

Member
hello I'm using a runtime item pick up for a weapon, I want to change the size of the hitbox but the hard part is that it works off a spawned object, and I can't find where I can alter the size of the hitbox from the source object to effect the hitbox of the spawned first person object. Is there a place I'm missing for this or do I have to do it again in item creation?
 
There isn't a built in way to modify the size, but you could get a reference to the collider using GetComponent on the Item's Object field. You can then modify it to any value.
 
where does the model decide to generate a box collider for the hit box, is it just matching the size of the model?
 
I think so. But as Justin suggested, you should be able to just get a reference to the gameobject via the Item component and set its collider size directly:

C#:
var item = m_Inventory.GetActiveItem(0);
var itemObject = item.GetComponent<ThirdPersonPerspectiveItem>().Object;
var boxCollider = itemObject.GetComponent<BoxCollider>();
boxCollider.size = ...
 
Top