Download

Moving ball towards vector location

I am trying to take the ball example and move it over to mouse input, to follow traced world location via the Convert Mouse Location to World Space node. From the debug I have, it looks as if the mouse and trace location are working correctly but when I add torque to the sphere physics actor, it doesn’t follow the direction from it and the mouse world trace location.

Here is the different blueprint layouts I have:

This is the debug I have going. The red sphere around the ball represents the sphere component location and the blue line is representative of the direction between the ball location and the mouse trace location. The red arrow is the direction the ball is moving when this image was taken.

This is what I am doing to trace the mouse location into the worlds 3D space:

And here is the logic that takes the different locations and tries to add torque to the sphere physics:

I am not great at the vector math stuff which leaves me wondering if I am simply missing a concept of using the two vector locations to get a direction. I am also wondering if multiplying the TorqueSpeed float is altering the resulting vector between the Sphere component location and the mouse trace vector location in a way to make it so the sphere is getting a wrong direction.

Thanks.

I think you need to subtract the mouse location from the ball location (currently you have the order backwards) then normalize the resulting vector and then multiply by the torque speed.

Edit: actually the subtraction is correct, try normalizing though and see if that does the trick.

Hey TK-Master, thanks for the reply. I am still have the same issue after normalizing the vector result of the subtraction between the sphere location and the mouse location. Below is a gif of how it looks running in game, maybe that will give some more insight.

Turns out that it has to do with the Add Torque node. Using the Set Physics Linear Velocity works.

Kind of strange…