Convert property value to force.

Hi guys, I’m stuck with something. I’ve tried a few times to create a mini golf game, but I get stuck at first hurdle, hitting the ball. At first I used modeified mouse scripts to swing a a club to hit the ball which worked for about 80% of the time but every now and again the club would swing straight through the ball (bullet physics) so thats not really an option it appears.

So the other way is to use a power bar which would convert a property value to a force which is much more reliable. Problem is I can’t figure out how to do it, ive looked at some of the examples from the game contest (wreck-o-deck for example) but the python is too complex for me to figure out. So I wonder if anyone would be kind enough to provide an example or point me in the right direction.

I dont usually do these ask-someone-else-to-do-it threads but i’m sure it’d be helpful to a more than just me. :slight_smile:

Im also wondering, as I remember a couple of people wanted to do mini golf games but non appeared in the contest did you run into similar stumbling blocks?

Thanks for any help.

Umm…I’m sure your problem is more complicated than I realize, but couldn’t you just use an actuator to add a certain amount of force to the ball at a certain instant?

act = cont.getActuator("MotionActuator")
own = cont.getOwner()

#On y axis only, because the orientation of the ball would change as part of
#gameplay, adding force locally will make that an option.
act.setForce(0, own.powerbarvalue, 0, 1)

GameLogic.addActiveActuator(act, 1) #turn actuator on

#Clear out the value of the power bar, so that force is not constantly applied.
own.powerbarvalue = 0  
#alternativelly you can have a timer cutting off force at 
#a certain time, instead of at the instant.

Hope this helps a bit.

I’m attempting one right now in fact, and I’ve given up on the golf club. At high speeds, bullet (interesting name, huh?) doesn’t exactly work properly. I would use the power bar option

Thanks Social thats seems to be what I was looking for.

there is a simple way of doing it… with an animated ipo golf club set to flipper… with acceleration curves in your IPO… you need to know how to draw your tangets to get this… anway… as long the club is acclerating… and you play it using flipper… you can get variable force… but it’s not very accurate… I made a catapult like this… I also parented the ipo say “golf club” to an empty that could be rotated… so you can have the animated swing and rotate the club on it’s axis in someway… this would translate into hitting the ball and I could easily shoot the ball at diff angles with diff amounts of force… tho if you hit to fast it would the ball would pop a bit through the catapult thrower thing… just gotta play with the speed of the IPO till it works?

hope any this helps…?