For a map, I'd like to have a dynamic way of a bounce system, like physically correct ways of being reflected. I'm aware of that reflected point system, but I thought there might be a way (with or without triggers) of having an object bounce correctly at every wall, no matter the direction (though, small hint for the case it helps: each wall got a terrain height being higher or lower than the playable area). Sure, it's possible to make 1 trigger and 1 region with many shapes per wall type (like top wall, bottom wall...) but this may not work at some parts for the map I am creating, thus it would be better to be able to only put 1 region on a wall and, no matter from what direction, the object bounces correctly. Important note: not only 1 object is flying at the same time, there is no fixed amount.
I might have repeated myself some times, but I wanted to ensure that you understand me correctly.
I'm really stuck on this, so please help me :)
I've gotten a 2D bouncing system working out for missiles, is that what you're after? Ie reflections occur based on cliff angle but they don't care about Pitch angle.
Okay well I'll give you the run down of how I made mine then since the module I want to release isn't quite ready yet: Essentially you need invisible objects who's whole purpose is to represent the facings of the cliffs, so once you have those created in the data editor you next need a whopper of a trigger that runs when the map loads and puts them everywhere. Essentially I had a double-for loop that ran for each square of the map and put down four points at its corners, compared their heights and based on that info decided whether it was going to put one of those objects down or not and which direction to make it face. As you can figure, this script generates *alot* of them for maps with many cliffs.
Next you need another trigger that rapidly checks all direct fire missiles currently on the map to see if they're within say .5-1.0 distance of one of these points and if that's the case to run your 'bounce' trigger. Now the bounce trigger needs to know the facing angles of both the missile and bouncer, and using some math that Xeridanus kindly provided in this thread: http://forums.sc2mapster.com/development/map-development/1884-any-mathematicians-out-there/ you're able to come up with the new angle for the missile to be heading.
Now, I don't know of any way to permanently change the heading of a missile once its launched so this got ugly(movers really stick to their agenda once in motion), what I did was first setup variables and set them to hold the information of where the missile was facing and how much time was left on it's travelling ability. Then a trigger to change its facing (this doesn't stick, but for this split second it actually does what it needs to) and call upon the same effect that originally created it to make another one aiming in the new direction, next you destroy the old one and using the previous variables impart the TTL info and anything else upon the new one...and voila the illusion of a bounce. :)
To see it in action check out the link in my sig, there is a video in there that demos a map I just released that features bouncing missiles...or better yet if you're on a US server search for the map and try it out.
I'm working on this now. After a collision is detected (this is all in 3d, by the way), simply sample 3 terrain points centered around the point where the collision was detected. That will give a triangle, which you then find the normal of. The normal of the triangle, combined with the current vector of the projectile, is all you need for realistic and accurate 3d collision resolution between cliffs and projectiles.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
For a map, I'd like to have a dynamic way of a bounce system, like physically correct ways of being reflected. I'm aware of that reflected point system, but I thought there might be a way (with or without triggers) of having an object bounce correctly at every wall, no matter the direction (though, small hint for the case it helps: each wall got a terrain height being higher or lower than the playable area). Sure, it's possible to make 1 trigger and 1 region with many shapes per wall type (like top wall, bottom wall...) but this may not work at some parts for the map I am creating, thus it would be better to be able to only put 1 region on a wall and, no matter from what direction, the object bounces correctly. Important note: not only 1 object is flying at the same time, there is no fixed amount.
I might have repeated myself some times, but I wanted to ensure that you understand me correctly.
I'm really stuck on this, so please help me :)
Huge thanks in advance.
Example:
Can this be done via the data editor? just curious.
I've gotten a 2D bouncing system working out for missiles, is that what you're after? Ie reflections occur based on cliff angle but they don't care about Pitch angle.
Ya, only 2d needed :)
Okay well I'll give you the run down of how I made mine then since the module I want to release isn't quite ready yet: Essentially you need invisible objects who's whole purpose is to represent the facings of the cliffs, so once you have those created in the data editor you next need a whopper of a trigger that runs when the map loads and puts them everywhere. Essentially I had a double-for loop that ran for each square of the map and put down four points at its corners, compared their heights and based on that info decided whether it was going to put one of those objects down or not and which direction to make it face. As you can figure, this script generates *alot* of them for maps with many cliffs.
Next you need another trigger that rapidly checks all direct fire missiles currently on the map to see if they're within say .5-1.0 distance of one of these points and if that's the case to run your 'bounce' trigger. Now the bounce trigger needs to know the facing angles of both the missile and bouncer, and using some math that Xeridanus kindly provided in this thread: http://forums.sc2mapster.com/development/map-development/1884-any-mathematicians-out-there/ you're able to come up with the new angle for the missile to be heading.
Now, I don't know of any way to permanently change the heading of a missile once its launched so this got ugly(movers really stick to their agenda once in motion), what I did was first setup variables and set them to hold the information of where the missile was facing and how much time was left on it's travelling ability. Then a trigger to change its facing (this doesn't stick, but for this split second it actually does what it needs to) and call upon the same effect that originally created it to make another one aiming in the new direction, next you destroy the old one and using the previous variables impart the TTL info and anything else upon the new one...and voila the illusion of a bounce. :)
To see it in action check out the link in my sig, there is a video in there that demos a map I just released that features bouncing missiles...or better yet if you're on a US server search for the map and try it out.
I'm working on this now. After a collision is detected (this is all in 3d, by the way), simply sample 3 terrain points centered around the point where the collision was detected. That will give a triangle, which you then find the normal of. The normal of the triangle, combined with the current vector of the projectile, is all you need for realistic and accurate 3d collision resolution between cliffs and projectiles.