Hey there,
I do wonder, is there any perfect bouncing system?
I'm currently trying to have phoenixes(?) bounce off cliffs perfectly.
Physically correct, just like the green shells in mario kart.
I tried it myself and it is working, but not perfect; it is bugging now and then and I don't know how to fix that.
My attempts is to periodically check whether there is a cliff between the position of the unit and like 2 units to where it is facing.
If so, it's facing is adjusted.
However, the checking apparently is to slow and no matter what it would never work flawlessly this way, I assume.
Is there any different, rather perfect system?
Please report errors in the Staredit.Network forum.
An artist's depiction of an Extended Unit Death
There isn't an event for detecting when a unit reaches a different terrain height, if that's what you're asking; a periodic event is probably the best you can do.
To calculate the correct new facing angle of the unit, you'll need to know the angle of the wall. In
another topic I figured the reflected angle to be (2*wallAngle - unitFacingDirection), but as you can see, the
attached map still had some issues with all of these factors considered (similar to the issue you described). Maybe checking ahead like you're doing could avoid the seizure-wall thing.
I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.
Since it's traveling straight under normal circumstances, can't you just scan the path and order it around when it reaches the position where you detected it to bounce? You would scan the line when you order the unit...
SC2 runs in 16 game frames per game second. That's the resolution you can work with.
edit:
You would have the following pattern:
- unit is created: scan straight for the next cliff change or other boundaries, then order it to execute the special transient ability that makes it calculate a new scan line and make it move a short way into the reflected position.
- that transient ability is executed: do the same as above...
Also, you might want to use custom values of a unit to store the facing the unit currently travels into. Then you won't lose the direction due to slow turning, etc...