Destructible Environments - Spawn In Exact Spot Issue
![Mack_Dundee](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I'm toying around with some shooter elements and I'm having a problem getting the walls to show destruction at the location at which they are shot by a gun. (When the bullet hits a wall, I'd like to show some blast damage on the wall.) What I've done is I've created a blast damage actor to spawn when a bullet hits the wall, but it keeps spawning in the middle of the wall, even when the bullet hits near the bottom of the wall. I've been looking through the forums and at about a dozen templates and the kinds of spawning I see are in general areas and not constrained within an area.
Here is the method I've tried to no success:
1) I created a game integer attributes called BulletX and BulletY. (I've also tried real attributes.)
2) In the bullet actor I've created a rule and two attributes.
Rule: actor-collides-wall
Change attribute: game.bulletx TO self.position.x
Change attribute: game.bulletY TO self.position.y
3) In the wall actor I've created a rule and a spawned actor behavior. (I've also tried using a timer before this one would take effect.)
Rule: actor-collides-bullet
Spawn Position: game.bulletx AND game.bullety
(Please note that I don't have any rules or behaviors for the blast damage actor - the one being spawned.)
Even if the blast damage actor were to appear directly over the edge of the wall in the exact spot where the collision occurred, I could work with that. I could just manually add or subtract pixels in the x direction of the spawn actor box to nudge the blast damage actor into place. But the y direction needs to have some precision for the effect to work.
Thanks for your time.
Here is the method I've tried to no success:
1) I created a game integer attributes called BulletX and BulletY. (I've also tried real attributes.)
2) In the bullet actor I've created a rule and two attributes.
Rule: actor-collides-wall
Change attribute: game.bulletx TO self.position.x
Change attribute: game.bulletY TO self.position.y
3) In the wall actor I've created a rule and a spawned actor behavior. (I've also tried using a timer before this one would take effect.)
Rule: actor-collides-bullet
Spawn Position: game.bulletx AND game.bullety
(Please note that I don't have any rules or behaviors for the blast damage actor - the one being spawned.)
Even if the blast damage actor were to appear directly over the edge of the wall in the exact spot where the collision occurred, I could work with that. I could just manually add or subtract pixels in the x direction of the spawn actor box to nudge the blast damage actor into place. But the y direction needs to have some precision for the effect to work.
Thanks for your time.
Comments
Thanks.
Another thing that kept setting me back on this was that I had a scrolling environment. Anyway, the tiny target area works fine even when scrolling.
Still, if anyone has any suggestions I'd love to read them.
Second place the spawn rule in your bullet not on the wall.
Rule.
if bullets collide wall
spawn Explosion actor to bulletx & bullety
--> set relative to scene.
@Drahc, as soon as I read your response I just shook my head! I tried all of these complicated things that I knew were only going to cause a slowdown when properly tested and the answer was so simple. Yes, the key is to use the spawn rule at the bullet and not the wall.
In fact, I don't even think you need to use attributes. You can just change the spawn positioning value to move the spawned actor to the correct spot (i.e., 10 pixels to the right relative to the actor). I don't see why this method wouldn't work with a scrolling background, but I'm going to test it. If it doesn't work I'll add to this thread just in case someone wants to try something similar in their game.
Otherwise, here's the concise way to do it:
Rule.
If bullets collide wall
Spawn Explosion actor
Front of layer
Position 0 & 0 (or adjust for proper placement)
Relative to actor
Thanks again, guys!