Moving Platforms, Liquid, All the Funky stuff

Official forum for the Chipmunk2D Physics Library.
dc443
Posts: 20
Joined: Sun Dec 02, 2007 3:54 am
Contact:

Re: Moving Platforms, Liquid, All the Funky stuff

Post by dc443 »

Shouldn't it still behave somewhat realistically even without rolling friction? If you have the frictions set right, and if you render your circles in a way that you can see their orientations, it should be rolling along as the platform moves. As for keeping it from falling off, well, that'd be a bit of an issue in real life too, if you had a moving platform and a ball.....
X-0ut
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am
Contact:

Re: Moving Platforms, Liquid, All the Funky stuff

Post by X-0ut »

Yes, the problem is that I'm trying to force it do something *unrealistic*.
The ball on a platform is a good example. But now think of a bike instead of a ball. If the brakes where on it wouldnt roll.
Anyhow, I'm about to give up chasing it. Tried so many different ways to accomplish it, and none worked quite right. Even tried aproximating a circle with a bunch of polygons.
So, it will probably just end up being a feature :)
dc443
Posts: 20
Joined: Sun Dec 02, 2007 3:54 am
Contact:

Re: Moving Platforms, Liquid, All the Funky stuff

Post by dc443 »

Are you simulating the body (frame) of the bike with a rigid body? To do brakes you'll have to somehow apply rotational friction between the frame and the wheels. I'm going to be implementing vehicle physics in my project, and this looks like something i'll need to deal with too.

In previous implementations (not using chipmunk) I hadn't actually made anything to serve as a brake because I was simulating a tank, so if I wanted it to stop I could just drive it in the opposite direction. The treads also helped slow it down. I drove the thing using torques applied on the wheels...

I think what you'll want to do to make a realistic brake using friction is to apply a sort of motor torque on the joint between the wheel and the frame of the bike. I don't know if this is implemented, or if you are even using a joint between the frame and the wheel, but it's simple enough, calculate the relative rotation and apply an equal and opposite torque to each point. If you're doing the bike separately, i guess you can get close enough by just applying a torque on the wheel that is in the opposite direction of angular velocity. That may not provide enough "grip" if you're aiming to completely stop the rotation though, because applying a torque proportional to the angular velocity might result in your circle slowly creeping down a slope if it were on one.

One other thing i've come up with is to just somehow "lock" the chassis of the vehicle (the bike frame) to the wheel when it's got the brakes on, so that there's no more relative rotation. I don't how how to best go about doing that, though. Perhaps some sort of combination of joints...

I'll get back to you when I'm done implementing my vehicles.
pTymN
Posts: 5
Joined: Thu Aug 23, 2007 12:25 pm
Contact:

Re: Moving Platforms, Liquid, All the Funky stuff

Post by pTymN »

Code: Select all

        (if (not (KeyIsDown (keypress-brakes input)))
            (let ((torque (* -2000000 power)))
                
                ; If engine is engaged, then there is internal resistance.
                (unless (= power 0) 
                    (setf torque (+ torque (* -200 (get-angular-velocity drive-wheel)))))

                (add-torque torque drive-wheel)
                (add-torque (- torque) chassis)
                
                (set-angular-mass wheel-angular-mass drive-wheel)
                (set-angular-mass wheel-angular-mass other-wheel))

            (progn
                (add-torque (* 361 (+ 
                                (* (get-angular-velocity other-wheel) (get-angular-mass other-wheel))
                                (* (get-angular-velocity drive-wheel) (get-angular-mass drive-wheel))))
                    chassis)
                                
                ; stopped using infinite wheel angular mass for brakes, so that i can
                ; get feedback on how much the wheels are stopping the car!
                (set-angular-mass (* 100 wheel-angular-mass) drive-wheel)
                (set-angular-mass (* 100 wheel-angular-mass) other-wheel)
                (set-angular-velocity 0 drive-wheel)
                (set-angular-velocity 0 other-wheel)
                (set-torque 0 drive-wheel)
                (set-torque 0 other-wheel)))))
Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests