Can’t seem to make this work…
What I’m trying to accomplish is the ability for the player (model) to throw a ball at whatever object in the world they click on. I’m not asking anyone to GIVE me the scripts (however, example scripts are GREAT!). I like to do my own work…but I just can’t seem to figure this out.
- Player clicks somewhere on the screen.
- Scripting determines if there’s an object within a certain distance from the player.
- If there IS…
- Have the player first face the object. Then throw the ball at that object. (Obviously will require some math to figure out how much force to apply to the ball to make it reach the target. This is an area where I need the most help.)
- If there IS NOT, throw the ball in the direction the player is facing.
I know this is going to require ray casting, but no matter how much I try, I can’t get the ray cast ScreenPointToRay to work with my game. I’m thinking it’s because I’m using a third-person and not a first-person. I have the mechanics in place already to have the ball instantiate in the player’s hand, the animation of the player throwing the ball, and the mechanics which tells the game to release the ball from the player’s hand once it’s at its apex. So I’m just in need of help to figure out how to make the ball’s trajectory, the place where the player clicked.
Thanks in advance for all help!