Jump to content


Photo

Bullet damage like a line of sight


  • Please log in to reply
4 replies to this topic

#1 123jimmy457

123jimmy457

    GMC Member

  • GMC Member
  • 44 posts

Posted 13 May 2011 - 10:17 AM

I am making a Nazi zombies game and i want my bullets to be created from my character to the nearest solid object and colide with every zombie in between give it a collatoral damage.

I dont know how to do this please someone explain or post a code example

I have pro and drag and drop are acceptable

Better explenation

O = player
- = bulletline
S = solid object
z = zombie

O----z-----z----z----S

All 3 of the z's should get damage but not stop the bullet line from going through.

the zombies are solid, if this is a problem i can change this.

Edited by 123jimmy457, 13 May 2011 - 10:33 AM.

  • 0

#2 borut

borut

    Courage Wolf Productions

  • GMC Member
  • 1266 posts
  • Version:GM:Studio

Posted 13 May 2011 - 11:14 AM

change bullet to non solid as same as zombies.
then do:
if(bullet.x=zombie.x and bullet.y=zombie.y)
{
instance_destroy(zombie);
}
  • 0

#3 123jimmy457

123jimmy457

    GMC Member

  • GMC Member
  • 44 posts

Posted 13 May 2011 - 11:21 AM

change bullet to non solid as same as zombies.
then do:
if(bullet.x=zombie.x and bullet.y=zombie.y)
{
instance_destroy(zombie);
}


The zombies have health and i need the bullet to be gone in 1 step and not having it fly first.
  • 0

#4 borut

borut

    Courage Wolf Productions

  • GMC Member
  • 1266 posts
  • Version:GM:Studio

Posted 13 May 2011 - 11:57 AM

then replace instance destroy with health-=1;
  • 0

#5 NilsAnders

NilsAnders

    GMC Member

  • GMC Member
  • 527 posts
  • Version:GM8.1

Posted 13 May 2011 - 12:46 PM

When you shoot he wants any zombies in between the gun and the first wall it meets to get damage. There is no actual bullet shown.

To do this however, might be harder than you think especially making it fast...
I suggest just checking in a while loop or for loop a line using lenghtdir_x and lenghtdir_y untill it meets the wall (or zombie but do not break the loop then just damage the zombie) or untill the maximum checking distance is met (bullet range) If you use a while loop make sure it BREAKS otherwise your game freezes.

Try this yourself otherwise i might look into it for you :)
Like said this is not a very fast method but it works..

Take Care
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users