Jump to content


Photo

Destroy object after 3 hits


  • Please log in to reply
10 replies to this topic

#1 beeproductions

beeproductions

    Helping gmc users

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

Posted 13 October 2010 - 08:47 PM

Hello readers,

I'm working on a tds and I need some little help

I have a crate that I want to explode after 3 bullet hits(The crate it's a w3d object)

Ho can help me?
  • 0

#2 Manuel777

Manuel777

    InvaderGames

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

Posted 13 October 2010 - 08:52 PM

So its 3d?
  • 0

#3 JR3C

JR3C

    GMC Member

  • New Member
  • 214 posts

Posted 13 October 2010 - 08:59 PM

Well make the crate's hp to x3 of your bullets damage...
  • 0

#4 beeproductions

beeproductions

    Helping gmc users

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

Posted 13 October 2010 - 09:03 PM

So its 3d?

It's a fake 3D
  • 0

#5 lap202

lap202

    Programmer

  • GMC Member
  • 229 posts
  • Version:GM8

Posted 13 October 2010 - 09:13 PM

Your trying to do 3d when you can't even come up with this.... Variables is your answer

(Create)
hits= 3

(On contact with bullet)
hits-=1

(Step Event)
if hits < 1
{
instance_destroy()
}



You could also use hp in place of hits... then its more damage based...
  • 0

#6 Manuel777

Manuel777

    InvaderGames

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

Posted 13 October 2010 - 09:14 PM

OK then in the create event of the crate set up a variable 'hits' with value 0:
hits = 0;

Then in the collision event from the bullet against the crate:
other.hits += 1;
if other.hits > 2
 with (other) instance_destroy();

  • 0

#7 beeproductions

beeproductions

    Helping gmc users

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

Posted 13 October 2010 - 09:22 PM

OK then in the create event of the crate set up a variable 'hits' with value 0:

hits = 0;

Then in the collision event from the bullet against the crate:
other.hits += 1;
if other.hits > 2
 with (other) instance_destroy();



___________________________________________
ERROR in
action number 1
of Collision Event with object obj_bullet
for object obj_crate1:

Error in code at line 1:
other.hits += 1;
^
at position 1: Unknown variable hits
  • 0

#8 Manuel777

Manuel777

    InvaderGames

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

Posted 13 October 2010 - 09:24 PM

"In the collision event FROM the bullet AGAINST the crate."
  • 0

#9 beeproductions

beeproductions

    Helping gmc users

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

Posted 13 October 2010 - 09:38 PM

I've tried lap202 code and it's working.What I want next (if it's possible) after every hit to flash(like in the image below) and maybe a explode effect after 3 hits.?plss,,,

Posted Image
  • 0

#10 Travis123

Travis123

    GMC Member

  • New Member
  • 44 posts

Posted 13 October 2010 - 10:37 PM

If it's 30 steps/second

on collision bullet with crate
set timeline cratehit (Not code)


Timeline:
at 0;
sprite_index = crate_hit
at 9;
sprite_index = crate_normal

For an explode:
Crate step:
if hits < 1
{
instance_change(explosion,0)
}
Explosion object end animation:
instance_destroy()
Send me a message via pm if you need anything else.

Edited by Travis123, 13 October 2010 - 10:45 PM.

  • 0

#11 beeproductions

beeproductions

    Helping gmc users

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

Posted 13 October 2010 - 10:55 PM

@Travis123: THX a lot for helping..I will send you a PM if I have another problems..:)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users