How to make slice effect for both vertical and horizontal directions?
I am seeking to make a slice effect that if I use a blade to slice the rectangular twice (one vertically and one horizontally), the rectangular will be separated into 4 pieces (figure.1).
But when I tried to program it, it didn't work. It worked perfectly for slicing either horizontally or vertically, but when I tried to do both consecutively, it always had a problem. Sometimes the second slicing could not be proceeded; sometimes the rectangle was cut into 6 pieces (the big rectangle was made of 6 smaller ones)...most weirdly it depended on how fast I sliced... I think the problem is that the code wasn't able to detect if it's a horizontal or vertical slicing effectively so there was always a bug...
Here's how I tried to detect the orientation of the slicing/blade (behavior in the blade):
If blade collides with rectangle and abs(self.Motion.Linear Velocity.Y) >= abs(self.Motion.Linear Velocity.X)
Change attribute game.blade_vertical to true
Timer after 1 second Change game.blade_vertical to false
If blade collides with rectangle and abs(self.Motion.Linear Velocity.Y) <= abs(self.Motion.Linear Velocity.X)
Change attribute game.blade_horizontal to true
Timer after 1 second Change game.blade_horizontal to false
This has a problem that GS only recognizes ">="/"<="... if I put ">"/"<" the blade never worked...but if I put ">=" for the first one, the second condition never got activated...
Does anyone have an idea how I can improve or change my code to let GS detect the orientation of the blade correctly?
Thanks a lot in advance!