Hi there. So uh, I'm trying to make a projectile that when it hits a wall will travel along that wall and eventually disappear. There's plenty of examples of projectiles, and plenty of examples of objects that will travel along walls. I did some tweaking of my own to an example for 360 degree firing so that after traveling a short distance the projectile path will begin to curve downwards. That all works fine. Bullet launches, bullet hits walls and stops, bullet travels along walls. All nice and good.
Problem I'm facing is that the bullet stops too late most of the time, or too early other times. This leaves the object that will travel along the wall unable to do so because it's either too deep or floating. I've tried a few techniques to prevent this, such as getting its X and Y when it's not overlapping an object and moving it there when it does, or attempting to pull backwards on its traveled path when it's inside a wall, but no luck. I've also tried running the code in a fastloop and a foreach loop, as I'll get into in a sec, but I guess I set it up wrong because they didn't do anything different.
When things are at just the right angle and distance then yeah, the projectile stops where it needs to and the object created will travel along the backdrop. Works fine. But that's only in the perfect scenario. I need to be able to just launch the projectile and it behave properly. I figure a proper fastloop would give me perfect collision detection, however I'm not sure how I would implement it in the current setup I have. I really like how I can make projectiles have a bullet drop mechanic and accurately rotate to match its path, and I'm afraid I'd lose that if I go into a fastloop system. Obviously if I knew what I was doing I wouldn't, but that's why I'm here.
How would I implement this system into a fastloop (or really a foreach loop would probably be better so I can fire multiple projectiles and have them all behave properly and independently) so I can have proper collision detection?
Just as a heads up, the projectile itself can be as simple and static as needed. It's just a mask. The projectile the player will actually see will exist on another layer. However, if a major rewrite is needed to get this collision detection working, I would like to also have a heads up on how I can get that mask to properly rotate based on the trajectory of the mask. Right now in the actual game it just sort of mimics what the mask is doing, but if the mask behaves differently then I still need the projectile to properly follow the mask and rotate to its traveling direction (and not like an 8 direction rotation. That might look a little weird depending on the angle it's moving).
Here is a link to an example .mfa I set up. Arrow keys move and select the direction you fire in, space shoots. Any help would be greatly appreciated, thank you.