-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wonky missiles algorithm #12
Comments
Non-random 'semi self correcting wobble', could be done by overlaying a sine wave on the missile's bearing. The period of the wave would determine the max error when missile reaches target. But how to add randomness to this? |
What about some kind of scheme where random bits were used to pick a selection of periods, but somehow ensure that when all the periods were summed up, the target was about the same at the max missile distance? |
sin(t/7) would cause the problem as t varies with respect to frames. You can try to change it to exp(-t/7) which produces decaying velocity. Or change to |
Missiles have a 'maximum range' value.. what about something like assuming they will travel half of that and make two splines, one for each leg. Someone else suggested using splines too |
I'll hopefully have another shot at it this weekend |
I think we should stick with less wonky curves which are easier to implement from both sides like parabola or elliptic. By the way, do you know if javascript/typescript has a linear algebra library which could perform vector multiplication and matrix inverse? If yes then I only need to explain the idea. |
This is code I can copy, thanks so much for this :) But looking at it, does this mean the wonky missile will always follow same path? Can we introduce some random seed into it somehow? |
There are several options to modify the trajectory by adding randomness.
|
wonky curves using spline Detailed implementation
Then we interpolate middle values
Random midpoint selection
|
I think I need some help in nailing this, if anyone is interested.
The hack posted to Reddit is fun but we could do way better, I'm just not sure how.
Some restrictions:
Ideas
Sub-ideas:
Problems:
I wouldn't mind nailing it in frontend first, so that if it's necessary to patch it into Starmash that only needs to happen once, and it only needs copied into server once
for usopp:
client fires,
server 'spawns a mob', that message includes a bunch of variables, but most importantly (speed.x, speed.y), where e.g.
etc.
(x, y) are set based on angle of plane when it fired
For every frame, and for whatever reason for fractions of a frame, some calculation runs that can modify the speed and absolute position (which usually updates from speed)
It calculates a number 0..1 ("fracFrame") depending on how much of a full frame's worth of change should apply, so you can write
And things work out.
In my messing around, I summed 'fracFrame' up over each call into a variable 't', so it turns into the number of frames the missile has been alive for. Then I divided that number down and passed it into Math.sin() and added that to speed.
There is also 'spriteRot' which is the angle it's being fired at. I think the correct application is something like
But this caused an insane stop-start missile that made no sense at all.
We can also modify position directly, rather than via speed. But speed seems to be the correct variable to change
The text was updated successfully, but these errors were encountered: