Author Topic: Bullets and invisible blocks problem  (Read 1497 times)

128-Up

  • Spike Dodger
  • Posts: 114
  • Lives are an antiquated concept.
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 48.0.2564.109 Chrome 48.0.2564.109
    • View Profile
  • Playstyle: Keyboard
Bullets and invisible blocks problem
« 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).

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 48.0.2564.109 Chrome 48.0.2564.109
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: Bullets and invisible blocks problem
« Reply #1 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!

128-Up

  • Spike Dodger
  • Posts: 114
  • Lives are an antiquated concept.
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 48.0.2564.109 Chrome 48.0.2564.109
    • View Profile
  • Playstyle: Keyboard
Re: Bullets and invisible blocks problem
« Reply #2 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?

L4Vo5

  • Cherry Eater
  • Posts: 59
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.116 Chrome 48.0.2564.116
    • View Profile
  • Playstyle: Keyboard
Re: Bullets and invisible blocks problem
« Reply #3 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
I have to admit, i still haven't beaten IWBTG