Help - Physics Space Ship Demo Need Help with picking object

This forum is currently in read-only mode.
From the Asset Store
Spaces Ambience contains 102 Sounds: 53 track and 49 sounds
  • Hello all,

    I am building a simple Space Ship / Asteroid shootem up Demo to help me learn the Physics behavior. But I have run in to a problem. The Big Asteroids are not being killed off like they should. The Asteroids have ID and Damage Private variables. In the game when a Big Asteroid gets 100 Damage it is killed and 3 smaller Asteroids replace it. But it is not working right. In debug I see the Damage goes above 100 but does not kill the big Asteroid.

    So if anyone can take a look and see whats wrong with it. I know it must be something simple I missed with picking a object.

    Use the arrow keys to move ship

    Use spacebar to shoot

    Made with Costruct Ver 0.98.9

    http://dl.getdropbox.com/u/1244375/SpaceShipDemo3.cap

    edit to add file.. It was a little to big to upload here.

  • You don't need to ID the asteroids at all.

    And you're using a System compare to compare the asteroid damage value. The system doesn't know which asteroid you mean, so it's picking the first one, and watching that one. When that one goes kablooey, all the asteroids are destroyed because you don't have a sprite picked.

    Use the asteroid sprite's own Compare Private Variable condition to check whether it's own damage is equal or greater to 100, and it works just fine.

    You also need to "Remember picked objects" when you spawn your small asteroids with a function, so Construct knows which big asteroid to spawn from. Otherwise, when you kill asteroid 2, 3, or 4 then asteroid 1 will spawn the small asteroids because Construct can't remember which asteroid it was working with.

    Also, you should check out the Custom collision mask for the astroids... with physics behavior you can draw a polygon around them to define a mask.

  • I think your over complicating your code. Also, to pick objects by value comparison, store the value in a private variable because System compare doesn't pick objects.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks deadeye for the tips. Ill give them a try and see how it goes.

  • Yep deadeye your tips were right on target:)

    The System compare was my problem. I knew it was something simple I was missing.

    And thanks Davioware, now that I know that the System compare was my problem. I took out the extra code I put in tp track down the problem.

    http://dl.getdropbox.com/u/1244375/SpaceShipDemo4.cap

    And if you or anyone else see anything else that could streamline the code let me know. Thats why I am doing this little demo project to learn how to code better in Constuct. And if you know any tips or tricks I like to see them.

  • Also, you should check out the Custom collision mask for the astroids... with physics behavior you can draw a polygon around them to define a mask.

    deadeye I can see that with something that stays the same size. but I am randomly changing the small astroids size. How would that work?

  • I dunno. Maybe you could make a few different types of small asteroids and spawn random ones.

    It'd probably look better than stretching them, too.

  • Nice demo, but something is fishing up the keys

  • something is fishing up the keys

    luigi's hands?

  • Nice demo, but something is fishing up the keys

    Thanks andla,

    Yes this little demo is far from done. I just got the basic engine done now. I have to get the HUD redone, right now it is set up for testing.

    Get the scoring going and add lot more stuff to blow up

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)