Impact Speed on Actor...

richcoyrichcoy Member Posts: 211
edited April 2012 in Working with GS (Mac)
I'm still working on my block based game. I'm trying to figure out how to have glass blocks that break only if hit by something moving at, or above, a set velocity.

I watched TshirtsBooth's video on impact speed but that was only testing one balls speed, and that was set to a game attribute. I'll have several actors moving around that could hit my glass block so testing against a game attribute does not seem possible.

The logical way would be to do a check when a block hits the glass ask the block how fast it is moving but I don't think that is possible in GS.

Any tips? Thanks.

Rich

Best Answer

  • iTopGamesiTopGames Posts: 71
    Accepted Answer
    Hi Richcoy

    I guess you have actors moving around your scene, right? heroes or thinks that collides with another thinks and gets the velocity for that reason, so for every actor that could break the glass make two real game attributes for and call them actor1velocityx and actor1velocityy if in your game the actors move in both directions, if they just move in one direction then only use that one.

    After that constrain in every actor: (game.actor1velocityx) to (self.Motion.Linear Velocity.X)
    (game.actor1velocityy) to (self.Motion.Linear Velocity.Y)
    Then make a rule on the glass:

    When: Any conditions are valid

    Attribute: game.actor1velocityx > (is bigger than) : "XXX" (here you set the minimum velocity for the glass break)

    then press + and add

    Attribute: game.actor1velocityy > : "XXX"

    And so for for every actor that could break the glass

    Then in the rule put the Destroy behavior or change image behavior if you want it destroy in steps.

    I hope it helps you.

    Let me know if it works for you.

    iTopGames

Answers

  • heathccheathcc Member Posts: 113
    Perhaps you could check the linear speed of the actors (self.Motion.Linear.X or Y) when they collide do the math between them to see what the difference in speed was?
  • UtopianGamesUtopianGames Member Posts: 5,692
    You could do the same as TSB and have several balls with several game.speeds.

    In the block actor you could check when it is hit by ball 1, ball 2 etc and then check the speed.

    Not watched the vid so not sure how he has it set up but its very doable.

    Darren.
  • richcoyrichcoy Member Posts: 211
    Well Might have this figured out though it seems really buggy.

    I created a game attribute called ImpactSpeed and if an actor overlaps or collides with the glass actor it changes the game attribute ImpactSpeed to magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ) of the actor that hit the glass.

    I then have the glass actor with a self attribute of ImpactSpeed that it changes to the game attribute ImpactSpeed. Right now I'm just displaying text of ImpactSpeed and sometimes it registers a number but most of the time it does not.

    Rich
  • richcoyrichcoy Member Posts: 211
    Shoot, just realized another issue. If the glass block is sitting on top of another collidable block then that triggers the test. I need the test to only occur if a new block touches the glass after the level starts.

    @UtopianGames Darren, the problem with your suggestion in this case is that I'll have up to 20 blocks on the screen and any of them technically could hit the glass if the player explodes another block and they fly around. It sounds like a nightmare to have 20 game level attributes to track just to break a glass block.

    Rich
  • richcoyrichcoy Member Posts: 211
    @iTopGames Thanks for the suggestion. It probably would work but with up to 20 actors on the screen that could hit the glass that would mean 40 game level attributes, and not every level would use all of them, sounds like a disaster to manage. I think I need to go back to the drawingboard and rethink the glass idea, not giving up yet but the current idea seems overly complex.
  • iTopGamesiTopGames Member Posts: 71
    Ok, take care bro.
Sign In or Register to comment.