How to apply physic on roulette's pointer

Here is my editor scene : https://playcanvas.com/editor/scene/946995
Just join playcanvas few week ago, not really familiar with it.
What i plan to do is when the pointer hit by the collider on the roulette it will rotate by itself in a limit rotation, and it will rotate back to the beginning rotation if didn’t got hit by the collider.

The pointer’s rigidbody is Dynamic and the collider’s rigidbody is Kinematic.
I had try to applyTorque and Force to the pointer.

This is the result I plan to make: https://youtu.be/Ntlv1MPUOMY

Hi, and welcome :slight_smile:

Hmm, how accurate do you want it? It can be faked, that is it will play a fixed animation, whenever it touches the collider. It will look a bit off, when the wheel is at the end of its rotation and will move slowly - the animation could be not matching the collider’s speed.

The other way, since you use physics, is to use the physics engine 6DOF spring to move the pin. It is a bit more difficult to set up than the fixed animation, but would give the best looking result I think.

Thank you for your reply @LeXXik

If I wanna make the realistic effect in unity which using the hinge joint, I have to use the physics engine 6DOF spring?
I will try to create an animation to test the result first to see the outcome of it.

Hmm, actually, you probably don’t need a spring. I will try a few things first.
Also, take a look at tweening tutorial, which might be helpful, if you want to use Tween library for animating it.

I tried the tweening on the pin, and play around with the rotation and duration value it still look kinda off :thinking:

Yeah, I would assume it would. By the way, have you tried to use a hinge joint, as you would in Unity?

There is hinge joint in Playcanvas? I dont know about that :dizzy_face:

Ah, yes, it has :slight_smile: Well, Playcanvas is using Ammo.js (which is a direct port of Bullet physics engine). As such, you have access to all its constraints types. Here is an example, that shows how to use Ammo’s point to point constraint. The same way you can use it to apply a hinge constraint.

var constraint = new Ammo.btPoint2PointConstraint(bodyA, pivotA);
var constraint = new Ammo.btHingeConstraint(bodyA, pivotA, true);

You can find the available hinge contructors in the Ammo sources.

Thank you, I will work with it until I get the result I want :grinning:. Thanks again. :grin:

1 Like