Vector Math Question

Ok, so i building a 3d marble style platforming game, however, when my ball travels fast in the X and Y directions through the air and lands, the ball doesn’t stay on the ground long enough for the friction to kick in and allow some sort of bounce control (video). In order to counter this, i want to manually apply an opposing force that is a percentage of the current magnitude of the velocity in the X and Y direction (say around 0-75% since i don’t want it to completely negate the horizontal movement)

In order for this to work however, i basically need to take the direction of movement, and then compare it to the direction that the sticks are pointing so that the force it only applied when the sticks are opposing the balls velocity direction. The camera will also be taken into consideration since i use the forward vector from the camera spring arm to apply movement force to the ball to begin with.

Im not super confident with vector maths, so i need a little help with this one if possible. Il post a few pics of the setup i currently ave so far (for my ball movement and for my landing impulse thing that i want to make).

Imgur

Imgur

Hopefully i explained it enough for someone to understand what im trying to achieve. It not, please dont hesitate to ask more specific questions.

Thanks!

Ok, not easy to go through your Blueprints without knowing more details about your project, so I will cover the basic principles here.

If you have two vectors and you want to check how much one is pointing in the same direction as the other or, viceversa, how much they are pointing in opposite directions, you should think of DOT product (also called Scalar product because it produces a scalar aka a float).

The DOT product calculates a number which represents the length of the projection of the first vector onto the second vector.

Let’s use unit vectors for simplicity. These are vectors of length 1 like those generated by the GetForwardVector or GetRightVector or GetUpVector functions.

If two unit vector are perfectly aligned in the same direction, their DOT product will be 1. If they are perfectly aligned but pointing in opposite directions, their DOT product will be -1. If they are perpendicular to each other (orthogonal) their DOT product will be 0 because there is basically no projection of one onto the other.

See here for a more in-depth explanation: Dot Product

You see where I am going with this. To recognize whether your joystick points in the opposite direction to the ball, you can take the ball velocity vector, calculate a DOT product with the joystick axis vector (I guess Y) and if the DOT product has a negative sign then they are opposite in direction, otherwise they point in the same direction. Quite simple once you grasp the concept.

That explanation of the dot product actually helped a lot so thank you for that. the main issue im having is with the camera rotation though. since the third person camera is not fixed in a single direction, my dot product will never actually be correct unless i use the rotation somehow.

You said you need to look at the direction of movement of the ball and compare it to the direction of movement of the joystick. What has this to do with the camera?

Take this image (my paint skills are amazing i know). The axis of the joysticks turns when the camera rotates around the ball

You can use UnrotateVector with the forward vector of the ball and the world rotation of the ball to always bring back its direction of movement to the horizontal and vertical axis, then you can do the dot product with the joystick axis. Give it a try. Use plenty of Print String to verify that is working properly.

Is this what you meant? it doesnt seem to be working so im assuming i have messed something up.

Video