I am developing a 3d table tennis game and so far I am successful in hitting the ball with racket, but the major problem is ball does travel but not bounce, it falls on the table surface after colliding it with racket and travel like a golf ball on the field I want to make it like a real table tennis ball.
Any suggestions, or any type of tutorial or example projects? Please Help
Have u tried to change the restitution value of the rigidbody of table?
Yes, I kept it minimum, still it bounce for a few mm , and then starts rolling on a table like a golf ball on a field.
what is minimum? and the golf ball rigidbody too?
I tried every possible minimum value from 0.1 to 0.01
and Yes for both the rigid body of ball and table
Maybe, but not sure, that the table must have a high value. I havenβt still played with restitution values
I tried everything with restitution values
Can u post the link to the project?
I am trying ball and paddle things in a public project so that once they are good enough then i can clone them in my private project, the project i am sharing is a test project.
https://playcanvas.com/project/434886/overview/ball-n-paddle-physics
p.s. The movement of racket is by arrow keys.
Instead of translate why donβt try with applyImpulse? I mean in the script
No Idea sir about applyImpulse, still in a learning phase.
this.arrow=app.root.findByName('Arrow');
var aarrow = this.arrow.clone();
app.root.addChild(aarrow);
aarrow.setPosition(this.entity.getPosition());
aarrow.setRotation(this.entity.getRotation());
aarrow.enabled = true;
this.force = aarrow.forward.clone().scale(4);
aarrow.rigidbody.applyImpulse(this.force);
this is a little example of the code i used to shot an arrow, the speed is pretty high so slow it down instead arrow u use ball of course but with some time spent u will be able to use it
PS this code is put inside the entity that shot the arrow/ball
Sir I will surely try, thanks for sharing
np welcome and good luck
I forked your project and looked at the ball shooter code. Youβve set the restitution to 0.01 of any new balls you spawn which is really low. As mentioned by @ayrin earlier in the thread, you needed to play with the restitution value to get your desired result.
More information about what restitution can be found on the Wiki page: https://en.wikipedia.org/wiki/Coefficient_of_restitution
In short, a value of 0 would be a perfect inelastic collision which would mean all energy is absorbed in the collision and there will be no bounce.
A value of 1 would be the opposite.
After removing the experimental code (not sure where you got this from), upping the restitution of the balls and floor to a higher number, I get the bounce I believe you are looking for:
// Add a new Model Component and add it to the Entity.
entity.addComponent("model", {
type: 'sphere'
});
entity.addComponent('collision', { type: 'sphere', radius: 0.1 });
entity.addComponent('rigidbody', { type: 'dynamic', mass: 1.0, enabled: true, restitution: 1 });
// experimental
//entity.rigidbody.body.setCcdMotionThreshold(0.001);
//entity.rigidbody.body.setCcdSweptSphereRadius(0.20);
https://playcanvas.com/project/435146/overview/ball-n-paddle-physics-forum
Thankyou so much steven, i was thinking the opposite in case of restitution.