Need help with mouse script on WIP

I am currently working on a fun little physics game for the BGE contest and would like to know if I could have some help with scripting. Although I am familiar with it, I have no idea where to begin on this one.(Maybe, get the mouse’s rayposition?) I would like it so that when you click somewhere, a ball will set its linV towards that point. I saw this on the forum earlier but my search came up negative.

Please help! i would love to finish this game!-YA

A blend:


Fallballexport.blend (964 KB)

This is probably no where near perfect as I’m not the best python/BGE logic person, but it may be what you’re looking for (see attachment)


clickmovetest.blend (229 KB)

This is nearly what I want. since the game will not be using the x-axis, I was thinking that the script should tell the ball to get the y and z position of the click, and set the linv of the ball in that direction. Problem is, I don’t know how to write it.


Is this what you are looking for? The world has zero gravity in my file, just to show what is actually happening.


trackMouseClick.blend (36.6 KB)

Yes! It is! There is just one thing: how do I make it so that when you click in a certain direction, there is a gradual buildup of speed? Also, how do I make it so that gravity is applied unless you click somewhere in the +Z axis?

Come back, Blendenzo! You sound like you can fix this!:eyebrowlift:

An update: I made it so that the ball rotates behind a billboard plane, since the reflection of the ball would never change. Added more colors. Working on sounds.

Had to take out a few things, due to file size.


Fallballexport.blend (797 KB)

Please! Help me! Save me from this state of ignorance!!!:eek:

If you use servo motion instead of simple motion, you can cause a gradual buildup of speed and specify a maximum limit on the speed.

I don’t know how you should best solve the issue of overcoming gravity. That could be rather complicated.

Yes… it would be complicated but…DUH!!! Servo motion was exactly what I was asking for!! I can’t believe I didn’t think of that!
The z-axis thing isn’t really necessary, but there is something that is…
The paddles in the blend are deigned to knock the ball off course: the whole goal of the game is to keep the ball from going off screen. I need to make the force of the pedals a priority over the movement of the ball towards the cursor.

Should I, like, Make it so that the linv is turned off when it is near a paddle?
…That could cause some bugs…