How do I spawn object at random pixel of collision area

Get help using Construct 2

Post » Wed Apr 08, 2015 6:11 am

Sample:

Image

2 objects collide/overlap and I want to spawn/create a spark object at any random pixel in the areas where the 2 objects collided/overlapped with each other (noted by the areas with red marks). I want to to be random but inside the overlapping areas only, so I can't use imagepoints.

Please help. Thanks.
B
16
S
7
Posts: 301
Reputation: 2,696

Post » Wed Apr 08, 2015 9:36 am

With create objekt than use the random command and add an X and Y interval for the random spawning.
B
11
S
2
Posts: 93
Reputation: 917

Post » Wed Apr 08, 2015 12:32 pm

@PlasmaGames2013

Is there an expression for only the area which is colliding/overlapping ? because that method, from what I understand, is using the object.x +/- random(number) but not really surely about the area of overlapping, so there is still a chance it spawns somewhere outside the overlapping area
B
16
S
7
Posts: 301
Reputation: 2,696

Post » Wed Apr 08, 2015 12:52 pm

Image
B
58
S
23
G
7
Posts: 1,437
Reputation: 10,553

Post » Thu Apr 09, 2015 9:06 am

@korbaach

Is there a way to make the spawned object not move at all? like in your example, the explosion just appears and destroys after animating without changing position? I tried disabling the bullet behavior, but it doesn't work like intended anymore
B
16
S
7
Posts: 301
Reputation: 2,696

Post » Thu Apr 09, 2015 9:34 am

I'm not sure what kind of effect you want to achieve exactly..

something like this?
Capx:
http://s000.tinyupload.com/index.php?fi ... 3900938476

OR?

capx:
http://s000.tinyupload.com/index.php?fi ... 1723860290
Image
B
58
S
23
G
7
Posts: 1,437
Reputation: 10,553

Post » Sun Apr 12, 2015 6:49 am

@korbaach
It's actually for a fighting game. When player1's attack hitbox punches player2, I can use player1 spawn spark at imagepoint 1 but I would prefer the spark to be spawn anywhere in the area where hitbox is overlapping player2.

In your example, sometimes the explosion is not spawned in the overlapping area. Is there really no definite way of doing it? I mean a definite absolute way of determining the overlapping area?
B
16
S
7
Posts: 301
Reputation: 2,696

Post » Sun Apr 12, 2015 9:11 am

To me it would seem like the perfect place to use imagepoints..
Depending on top hit or kick-leg or whatever, but if you want to know the overlapping area, it can be done.
I'm assuming the hitboxes are square/rectangular

Create 4 variables ValueYtop,ValueYbottom,ValueXleft,ValueXright

If hitbox1 is overlapping hitbox2
- Hitbox1.BBoxTop > Hitbox2.BBoxTop > ValueYtop = Hitbox2.BBoxTop
- else > ValueYtop = Hitbox1.BBoxTop

By comparing the boundingbox left, right and bottom you now get the 4 values of the top(Y), bottom(Y), left(X) and right(X) of the overlapping area.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go and 3 guests