Bullet Help!

skippertechskippertech Member Posts: 67
edited July 2012 in Working with GS (Mac)
How to make a bullet kill its shooter.

So in my game i have been working on, I have a tank like object that shoots bullets. Now I want to make this bullet kill the tank( that shoots it) if it bounces off the wall and hits it. So I mad a collison, but instead the tank gets killed right away because when it is "firing the bullet" it collides with it. SO i went in and made an attribute, that everytime it collides it adds +1 to the attribute, and when it gets to =2, the actor gets destroyed. Unfortunatly that didnt help because the second time I fire a bullet the actor gets destroyed. how can I make bullets like this. where after the actor fires them, if the actor gets hit by them he gets destroyed?

thanks so much

Comments

  • BarrytheBraveBarrytheBrave Member Posts: 134
    Here are a couple of ideas:

    You could add a self boolean attribute to the bullet called "bounced". Then add a rule so that when the bullet collides with a wall the bounced attribute changes to true, and the bullet only kills the tank if it collides with the tank and it's bounced attribute=true. (ie it has already bounced off a wall).


    Another idea:

    Each bullet (or any actor) will internally keep track of a self.time attribute that starts as soon as it it is created and counts up until it is destroyed. If you are using spawn to create the bullets then you could work out how long it takes for the bullet to leave the boundary of the tank actor (lets say this takes 0.5 seconds), and then have a rule in the bullet that says if it collides with tank, and it's own self.time>0.5 then destroy tank. This will make sure that the destroy action doesn't come in to play until the bullet has already left the tank.

    Just a couple of ideas, there may be better ways of doing the same thing!
  • MantoManto Member Posts: 796
    Made a project for you. Download
    Tell me if you're using windows version or want to ask something about the project.
  • skippertechskippertech Member Posts: 67
    Thats really nice of both you you! Mantu I am using windows. and ooj I will try that. thankyou
    Made a project for you. Download
    Tell me if you're using windows version or want to ask something about the project.
Sign In or Register to comment.