Can't convert mouse input to clamped angle in game

Hello,

I have a golf project I am working on and I’m running into an issue where the angle either shoots the ball into the ground and ‘doesn’t fire’ for the ball is unable to roll over an obstacle (hill, curve, loop).

image
This collects the mouse input. I’ve tried clamping this, but it results in an inability to spin the camera all the way around and shoot where you need.


This is where the forward direction is decided. Any clamping I did here resulted in the ball shooting in an direction besides forward.

I would like to set the Y value to be equal to the “ground level”. I want the ball to be hit at “center ball” and have the X axis be the only real “aiming”.

I’m sure I am missing something simple and advice would be greatly appreciated. Thanks in advance for your guidance.

Hi demonicheddgehog,

Were you clamping between 0->360 or -180->180?

Hello,

Sorry for my delayed response. I have tried quite a few options, including 0->360. I did not try -180->180. I just tried it now, and it’s still giving me problems.

The main two issues I’m facing are:

  1. The inability to get over obstacles. (This may be an issue with the mesh clipping, but I want to exhaust my options with the angle first).

  2. Occasionally, the fire “doesn’t fire”. It moves a negligible amount and wastes a shot. My hunch is that it’s firing down and into the ground.

I’m hoping that finding a way to restrict the angle will resolve both of those problems. I am thinking there may be something to not limiting the camera movement, but rather the “launch window”. I have toyed with a clamped range node, but it was a disaster.

Thanks again for the suggestion.

np, maybe add some “PrintStrings” in there so you can see the exact angles being used…