Bukkit - Low Velocity Snowballs - minecraft

everyone. I'm having a little trouble with launching snowballs. I'm working on a plugin where, while a user is holding a snowball, they can sneak to charge a power bar. The player has a scoreboard in the side_bar that has a "power bar" that goes up and down from 1 to 10 while they are snaking. Once they right click to throw the snowball, it launches the ball at a velocity dependent on the users power level. A level of 5 is the default speed, a level of 10 is double the default speed, and a level of 1 is a fifth of the default speed, and the rest fill in that scale accordingly. I do this by multiplying the velocity by powerLevel/5.
This is all working splendidly. Well... kinda...
If the power level is 5 or above, it does what I expect it to do. However, if the power level is below 5 (slower than the default speed), the snowball just drops straight down. Is there a reason this happens? Can it be fixed? Any help on this would be great.
Thanks in advance!

based on how much y velocity it has, the snowball will start to drop caused by gravity. to remove this, you would need to keep track of the snowball's y plane with the methods on this thread.
Calculate initial velocity to move a set distance with inertia

My guess would be that a fifth of the snowball's velocity is about dropping when you throw it. In order to fix it; you'll need to set the Y level higher so it doesn't fall.

Related

How to change axis velocity during Gcode operation

Good work everyone,
I have been working on a 3 axis CNC machine for a while. A lot of things are going great! But I couldn't find how to increase or decrease the axis speeds while processing the g code. I am using the SMC_INTERPOLTAOR block to manipulate the G code. I think I can overcome this problem with the 'dwtime' value in the entry of this block, but this does not offer a healthy solution.
I need support for this! I need to do an instant increase or decrease of the axis speed during a motion!
Thanks. / ByCNC
What is motion axis speed control problem method
While I have no experience with SoftMotion CNC libraries, looking through the documentation the dOverride input argument seems to be promissing:
... The scheduled velocity of the particular objects will get scaled by dOverride; thus the scheduled velocity can be increased resp. reduced in online mode...

Is there an optimal depth in a game tree?

I'm working on this game engine which plays some board game, I implemented minimax with alpha beta pruning, and move ordering. Now when I play with other existing engines, everything looks fine. However, I found two subtle problems which I don't know what causes them, maybe I have some gap in my knowledge.
The first issue:
When I increase the depth of the search, intuitively I should get better results even if consumes more time, but in my case moving from depth 8 (winning) to depth 9 causes me to lose all the time, now if I increase it to 10 I suddenly win again. Keep in mind that I keep everything constant except the depth. At first I thought that maybe its because at depth 9 we find a promising move at first which the opponent can refute it easily, but then this could happen at every depth. So my question is what causes this weird behaviour? Is there an optimal depth, which if we go beyond could backfires?
The second issue:
Its similar to move ordering but done to get the values of the next play to pick what to play. For example:
For every possible move starting from weakest move do:
minimax(move)
Now since we have to go through all possible moves why having the strong moves first wins the game but if I started with the weakest moves loses the game. It doesn't make since we have to evaluate all possible moves anyway. What causes this behaviour?
When I increase the depth of the search, intuitively I should get
better results even if consumes more time, but in my case moving from
depth 8 (winning) to depth 9 causes me to lose all the time, now if I
increase it to 10 I suddenly win again.
Certainly sounds like a bug to me.
For every possible move starting from weakest move do:
minimax(move)
You should always start from the strongest move in order to benefit from alpha-beta pruning
Now since we have to go through all possible moves
What about alpha-beta pruning? You do not have to go through all possible moves.

Kinect HandPointer coordinates

I am making an application that will somewhat work like the Kinect's WebServer WPF sample. I am currently trying to map hand positions to screen coordinates so they can work like cursors. Seems all fine and dandy, so let's look at the InteractionHandPointer documentation:
Gets interaction-adjusted X-coordinate of hand pointer position. 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge of interaction region, but values could be outside of this range.
And the same goes for Y. Wow, sounds good. If it's a value between 0 and 1 I can just multiply it by the screen resolution and get my coordinates, right?
Well, turns out it regularly returns values outside that range, going as low as -3 and as high as 4. I also checked out SkeletonPoint, but the usage of meters as scale makes it even harder to use reliably.
So, has anyone had any luck using the InteractionHandPointer? If so, what kind of adjustments did you do?
Best Regards,
João Fernandes
The interaction zone is an area for each hand where the users can comfortably interact. When the value is lower than 0 or greater than 1, the hand of the user is outside the interaction region and you should ignore the movement.
To those wondering, like kallocain said, if the value is greater than 1 or lower than 0 then tha hand of the user is outside the interaction region. The fact that the boundaries of this region aren't configurable is quite the bother.
When the values do go outside these values you can indeed choose to ignore them. Instead of doing that, I bounded them to the region in this manner:
Math.Max(0, Math.Min(hand.x, 1))
I hope this helps someone someday.

How do I calculate the location of an object that is both turning, and accelerating?

I am trying to write a simple game, but I'm stuck on what I think is simple physics. I have an object that at point 0,0,0 and is travelling at say 1 unit per second. If I give an instruction, that the object must turn 15 degrees per second , for 6 seconds (so it ends up 90 degrees right of it's starting position), and accelerate at 1 unit per second for 4 seconds (so it's final speed is 5 units per second), how do I calculate it's end point?
I think I know how to answer this for an object that isn't accelerating, because it's just a circle. In the example above, I know that the circumference of the circle is 4 * distance (because it is traversing 1/4 of a circle), and from that I can calculate the radius and angles and use simple trig to solve the answer.
However, because at any given moment in time the object is travelling slightly faster than it was in the previous moment, my end result wouldn't be a circle, it would be some sort of arc. I suppose I could estimate the end point by looping through each step (say 60 steps per second), but this sounds error prone and inefficient.
Could anybody point me in the right direction?
Your notion of stepping through is exactly what you do.
Almost all games operate under what's known as a "game tick". There are actually a number of different ticks that could be going on.
"Game tick" - each game tick, a set of requests are fired, AI is re-evaluated, and overall the game state has changed.
"physics tick" - each physics tick, each physical object is subject to a state change based on its current physical state.
"graphics tick" - also known as a rendering loop, this is simply drawing the game state to the screen.
The game tick and physics tick often, but do not need to, coincide with each other. You could have a physics tick that moves objects at their current speed along their current movement vector, and also applied gravity to it if necessary (altering its speed,) while adding additional acceleration (perhaps via rocket boosters?) in a completely separate loop. With proper multi-threading care, it would fit together nicely. The more de-coupled they are, the easier it will be to swap them out with better implementations later anyway.
Simulating via a time-step is how almost all physics are done in real-time gaming. I even used to do thermal modeling for the department of defense, and that's how we did our physics modelling there too (we just got to use bigger computers :-) )
Also, this allows you to implement complex rotations in your physics engine. The less special cases you have in your physics engine, the less things will break.
What you're asking is actually a Mathematical Rate of change question. Every object that is in motion has position locations of (x,y,z). If you are able to break down the component velocity and accelerations into their individual planes, your final end point would be (x1, y1, z1) which is the respective outcome of your equations in that plane.
Hope it helps (:

Modeling human running on a soccer field

In a soccer game, I am computing a steering force using steering behaviors. This part is ok.
However, I am looking for the best way to implement simple 2d human locomotion.
For instance, the players should not "steer" (or simply add acceleration computed from steering force) to its current velocity when the cos(angle) between the steering force and the current velocity or heading vectors is lower than 0.5 because it looks as if the player is a vehicule. A human, when there is an important change of direction, slows down and when it has slowed enough, it starts accelerating in the new direction.
Does anyone have any advice, ideas on how to achieve this behavior? Thanks in advance.
Make it change direction very quickly but without perfect friction. EG super mario
Edit: but feet should not slide - use procedural animation for feet
This is already researched and developed in an initiative called "Robocup". They have a simulation 2D league that should be really similar to what you are trying to accomplish.
Here's a link that should point you to the right direction:
http://wiki.robocup.org/wiki/Main_Page
Maybe you could compute the curvature. If the curvature value is to big, the speed slows down.
http://en.wikipedia.org/wiki/Curvature
At low speed a human can turn on a dime. At high speed only very slight turns require no slowing. The speed and radius of the turn are thus strongly correlated.
How much a human slows down when aiming toward a target is actually a judgment call, not an automatic computation. One human might come to almost a complete stop, turn sharply, and run directly toward the target. Another human might slow only a little and make a wide curving arc—even if this increases the total length to the target. The only caveat is that if the desired target is inside the radius of the curve at the current speed, the only reasonable path is to slow since it would take a wide loop far from the target in order to reach it (rather than circling it endlessly).
Here's how I would go about doing it. I apologize for the Imperial units if you prefer metric.
The fastest human ever recorded traveled just under 28 mph. Each of your human units should be given a personal top speed between 1 and 28 mph.
Create a 29-element table of the maximum acceleration and deceleration rates of a human traveling at each whole mph in a straight line. It doesn't have to be exact--just approximate accel and decel values for each value. Create fast, medium, slow versions of the 29-element table and assign each human to one of these tables. The table chosen may be mapped to the unit's top speed, so a unit with a max of 10mph would be a slow accelerator.
Create a 29-element table of the sharpest radius a human can turn at that mph (0-28).
Now, when animating each human unit, if you have target information and must choose an acceleration from that, the task is harder. If instead you just have a force vector, it is easier. Let's start with the force vector.
If the force vector's net acceleration and resultant angle would exceed the limit of the unit's ability, restrict the unit's new vector to the maximum angle allowed, and also decelerate the unit at its maximum rate for its current linear speed.
During the next clock tick, being slower, it will be able to turn more sharply.
If the force vector can be entirely accommodated, but the unit is traveling slower than its maximum speed for that curvature, apply the maximum acceleration the unit has at that speed.
I know the details are going to be quite difficult, but I think this is a good start.
For the pathing version where you have a target and need to choose a force to apply, the problem is a bit different, and even harder. I'm out of ideas for now--but suffice it to say that, given the example condition of the human already running away from the target at top stpeed, there will be a best-time path that is between on the one hand, slowing enough while turning to complete a perfect arc to the target, and on the other hand stopping completely, rotating completely and running straight to the target.