2D Toolkit Forum
2D Toolkit => Support => Topic started by: vambier on October 08, 2012, 09:50:51 pm
-
I want to add an empty object(full alpha) to my player, this object must be able to collide with other objects. What is the best way to achieve this?
-
Just manually add a boxcollider, or add a gameobject child with a boxcollider & rigidbody. Both will work.
-
Can I also change the shape of that collider, or does it have to be a box?
-
That will need to be a box / sphere, otherwise you'll have to build your own meshes somehow. You shouldn't really be moving a polygon collider anyway, its not exactly cheap...
-
Thanks, I don't know if it will cost that much in my game since I only have a couple of objects that have colliders at a time. But I'll see if I can make a custom mesh for this.
-
You can also do it like this if you want -
Create an empty texture (0 alpha throughout)
Import into sprite collection
Draw polygon collider
The sprite will be optimized out as its empty so won't take up any space in your atlas.
-
Yeah I tried that yesterday, but I got errors in unity(null reference if I remember correctly) when clicking "commit" in my spritecollection.
I just created a new sprite collection(also tried in an existing one), then added my full alpha sprite, turned on compression and set the collider to polygon.
Then I drew my polygon and wanted to click commit, and then I got the null reference error.
-
You could add one pixel of 1 alpha... its probably complaining because its cropping the image fully - I thought it'd work with the padding, but clearly not.
-
1 pixel alhpa helped! Thanks!