Adding force to an object the way we are looking

Hello everyone :slight_smile:

I would like to know if it is possible (and it really should be :p) to add force on an object when clicking on it, with this force beeing relative to the camera. Actually, i got in my scene a snooker and i would like it to be a bit interractive. I’ve managed so far to make every balls dynamics, i can click on the cue ball to make it go in the x direction to hit other balls, but the problem is that since i only use logic boxes i can’t hit the cue ball to make it go the direction i’m looking at.

The snooker is not the main element in my scene, i’d only like to make this possible to make the scene more friendly. I think i’ll have to make this with some python but the fact is that i don’t know how to do this. So after beeing doing some vain research i come here to ask if someone can help me.

Thanks in advance!

I assume you want the balls rolling around. You should use rigid body rather than dynamic ;).

Anyway, you are right that you need python. Hereis a quick and dirty demo:

You can also check other demos. There was a very old one in 2.42 BulletPhysics…something
or
you can look at the first person shooter demos. They use impulses too.

This demo has a glitch in applying the forces. But I have no time to check that right now.

Attachments

BillardDemo.blend (52.7 KB)

Got it.

The API says applyImpulse uses world coordinates for the point of impact. That is not true it uses local coordinates. So the point must be converted first.

Check the file

Attachments

BillardDemo_v1.1.blend (53.1 KB)

Now with strength

Strength is a float property.
The demo increases the property when holding LMK.
But it is up to you how you implement that.

Monster

Attachments

BillardDemo_v1.2.blend (55.1 KB)

Hello Monster,

Thank u very much for your quick and detailed answer :wink: I’ll check this soon and will give you feedback.
You’r right for the rigid body, i’ve actually used the rigid body but meant dynamic in the idea that balls are dynamic ; the opposite of static :slight_smile:

See ya!