# How do I create object in hitbox that isn't square?

0 favourites
• 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
• I have a large diamond shape that doesn't take up the whole screen, it does change size though.

The diamond and image size is 2 parts width and 1 part height.

100 width, 50 height

1000 width , 500 height... etc

What I currently have isn't using a hitbox. It works, but is a mess.

Is it possible to spawn objects in a hitbox that isn't square?

I suppose I could add hidden objects where I don't want it to spawn, but I usually try to avoid hidden objects.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Hello,

If you dont want to post a .capx you send me a PM with it.

Im not really sure about what you want but i thinks i can help. (Im french you can try to explain just what you want)

Best Regard,

Casimir

• Break up the shape in triangles, using imagepoints.

First choose a random triangle.

Then choose a random point like this.

https://www.dropbox.com/s/at7rdg1w357mu ... .capx?dl=0

• It seems exactly what I need, but It is confusing a small bit to me. I will have to dissect it.

I understand how to use it as it is, but would like to know a small bit more.

Why are you setting r1 and r2 to random(1) instead of just setting it to 1?

How is it picking a random point? The only random I see is random(1).

I never used or seen a random without two limits. Random(0, 10) etc.

Can you give a simple explanation for the rX and rY formula?

I do notice that one controls the X and one controls the Y.

• random(1) generates a number between 0 and 0.9999999999999999999

random(5) generates a number between 0 and 4.9999999999999999999

It needs 2 randoms, else the distribution will be more dense around the centre. (barycentre)

Explanation:

https://adamswaab.wordpress.com/2009/12 ... ordinates/

• Thanks, helpful as always.

• 6 posts
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)