I’m making a quick game for my brother and i have a problem now, i’m calculating hit point of a ball using raycast and got Vector3,
Now i’m using bullet physics and need to know how to apply simple force to ball? (relative to hit position, for ex: Left bottom corner, ball supposed to go right upper corner)
How can i calculate Force vector? i got Position vector from code.
You can e.g. set the relative position to your lower right corner and apply some force -The ball should automatically move towards the upper left.
(Take care of gravity, the movement could result in a curve instead of a straight line the stronger the gravity is)
Well… May be you could use the normal vector at the impact point ?
If this is a sphere, you can just draw a vector from the impact point to the ball center. Then just have to modulate with the strength of the kick.
[java]
Vector3f pt = results.getCollision(i).getContactPoint();
Vector3f force = ballCenter.getWorldTranslation().subtract(pt).normalize().mult(kick_force);
[/java]
@yang71 said:
Well... May be you could use the normal vector at the impact point ?
If this is a sphere, you can just draw a vector from the impact point to the ball center. Then just have to modulate with the strength of the kick.
Yes it is a sphere, with a SphereCollisionShape how can i get its center? is there a method or something?
Then how to calculate that vector? Vector3f.add or Vector3f.substract ?
I don’t get the ball pushed into the direction of the camera properly. The ball begins to rotate and starts rolling towards me (the camera position) with the following code:
[java]
Again, impact_point is local in this case, you probably want it to be 0/0/0 simply. You jave to apply forces when a physics tick is occurring, see the ohysics documentation.
The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless theres emotes that hint otherwise or there’s an increased use of exclamation marks and all-capital words.
@mathias4u said:
I there more physics documentation than "F1" and the Javacoc?
Proper research started before 1800 even and since Einstein it only became more interesting.. What exactly do you want to know? ;) The javadoc tells you what it does and the docs tell you how you are supposed to use it. Whats the question? :)
Btw, I always think “Balls, Physics, I need help from the Force” when I read this topic title xD Nothing about you though
The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless theres emotes that hint otherwise or there’s an increased use of exclamation marks and all-capital words.