Calculate trajectory and point of exit
Basically, I want to send bullets from one place to another while keeping the relative position and angles of trajectory...
So, what I have for now is Ham_TraceAttack hooked, I'm checking if the ending shot location was at least 20 units away from my defined location and I'm redirecting that shot with new angles... but I need to calculate exacly where in those 20 units the shot got in and make it relatively exit the same position and with the same relative trajectory. If this isn't understandable, I'll just post a screenshot, I can't now :} |
Re: Calculate trajectory and point of exit
|
Re: Calculate trajectory and point of exit
I don't get much from that :/ xs_* functions confuse me.
Still, I think I'll need a better "hit" detection first, something more concrete than range checking for hits on walls xD |
Re: Calculate trajectory and point of exit
It's really not that hard.
You just need to make sure the trace hits a wall, then reflect the direction off the wall. |
Re: Calculate trajectory and point of exit
I don't want to reflect it from the same wall, I want it to be continued somewhere else.
To be more exact, this is for the portal project I'm continuing to work on... if you shoot a portal it gets out somewhere else and the other portal can be on the same wall, on a floor, on a ceiling, on a slope so it's tricky xD Currently the shot only exits the portal directly from the center of it and goes straight, no matter the angles or position where you shot the first portal :/ |
Re: Calculate trajectory and point of exit
Okay, then what you could do is take the normal of the 2 walls, and get the angle between them.
Then, you can transpose that angle from the original trajectory to calculate the new one. |
Re: Calculate trajectory and point of exit
Well, I have the normal and the angles of both walls (barely xD) but I can't get the exit angle right... what do you mean transpose ? O.o can you give me an example using two angles or directional vectors ? (I have both)
|
Re: Calculate trajectory and point of exit
Something like this:
Code:
vecPair2 would be the direction towards the first wall vecOther would be the normal for the second wall vecResult would be the calculated direction for the second wall You would need to change the direction towards the first wall to be backwards (away from the wall instead of towards it) before you did this function. Or you could reverse the result. Example: Code:
|
Re: Calculate trajectory and point of exit
If the 2nd portal is on the floor or ceiling, it goes straight O.o The angles are right btw, because in straight line they go just fine on ANY surface. EDIT: lol fail, I used fDir directly in xs_vec_sub() instead of making it into an angle =) anyway, it works verry nicely XD thanks. Now for the next issue... it needs to exit the same relative position it entered... but for that I need to first remake the hit detection system. I think I'll make a new thin solid entity the size of that sprite and get hit detection on it... or is it possible to do it on sprites ? :-? |
Re: Calculate trajectory and point of exit
Relative position is easy as well.
Code:
|
| All times are GMT -4. The time now is 20:11. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.