Duck Game
十分な評価がありません
Collisionbox Guide
作者: Killer-Fackur
I will share my secret techniques so that you wont have to test values blindly 10 or more times just to get a somewhat accurate collisionbox
   
アワード
お気に入り
お気に入り
お気に入りから削除
Drawing out your collisionbox
Use any painting software that you like. I've only used PaintdotNET[www.getpaint.net] and it gets the job done, it only needs a way to measure rectangle sizes and prefferably layer support.

Start by creating a new layer and paint where you want your collisionbox to be (it has to be a square or rectangle).

Now Mark where you want the gun to rotate around and where you want the bullet to come
Applying the drawing to your weapon
I will be using the rectangle select to measure the distance and sizes of what we just drew. We'll start off by getting the collisionSize value, just select the area you drew and see how big it was.
this.collisionSize = new Vec2(26f,12f);

Next value is the center/rotation axis: this is measured by the distance from the top left corner of the sprite.
this.center = new Vec2(7f,12f);

Next up is the collisionOffset value: this determines where the collisionbox will start, and it is based of the center.
As the value is based of the center we're actually measuring from right to left and down to up instead of left to right and up to down, we have to invert the values so that its -12f,-6f instead of 12f,6f.
this.collisionOffset = new Vec2(-12f,-6f);

Offsets work like this: you have a start position and add an offset to get a position somewhere else, ie where the barrel is or to correct where the duck holds someting.
So where the collision box starts is the center (start position) + collisionOffset (offset).

Another offset is _barrelOffsetTL; TL standing for Top-Left which is the start of the offset. I will leave you with this knowledge and let you figure out the values yourself.
This is a test of how well you understood this guide, if things doesn't work as you intended you can always try reading the guide again or ask in comments.

Heres a couple of other useful offsets:
editorOffset //offset to position in the editor
holdOffset //offset to position when held
handOffset //offset to ducks hand when holding item

1 件のコメント
Ayusfv 2022年7月25日 11時23分 
a