I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: 128-Up on February 19, 2016, 06:34:29 PM

Title: Bullets and invisible blocks problem
Post by: 128-Up on February 19, 2016, 06:34:29 PM
How do you make it so that bullets can be stopped by invisible blocks (only after they've been touched) and fake blocks (only before they've been touched), as well as the usual regular block object stopping them?

The closest I've gotten is having the fake block part work but not the invisible block part worked (meaning they stop the bullets while still invisible).
Title: Re: Bullets and invisible blocks problem
Post by: klazen108 on February 19, 2016, 07:35:46 PM
Just check the the bullet object. There's a collision with block event there that destroys if it collides with a block, right? Try this in that event:
Code: [Select]
if (other.object_index==invisibleBlock || other.object_index==fakeBlock) {
    if (other.visible) instance_destroy();
} else instance_destroy();

Assuming all those blocks have block as their parent, then if the block is an invisibleBlock or fakeBlock, only destroy if visible. Otherwise, just destroy.

Change the names if they're not the same, and if the parents aren't block, just make a new new collision event for them. Should work just fine!
Title: Re: Bullets and invisible blocks problem
Post by: 128-Up on February 19, 2016, 07:46:29 PM
For some reason, the unseen invisible block is still destroying the bullets...

Is there anything else that might help?
Title: Re: Bullets and invisible blocks problem
Post by: L4Vo5 on March 12, 2016, 12:53:41 PM
Locate the collission event that destroys the bullet. Just putting "if other.visible = 1" before the "instance_destroy()" should work. Otherwise it might be a problem with the exact code. In that case you should paste the code here so we can (maybe) see the problem