Impact Speed on Actor...
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
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
-
iTopGames Posts: 71
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
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.
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
@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