GameMaker Fixture which is not influenced by room's gravity, but revolute joint motor can still rotate it?

Tornado

Member
Is it possible to have fixture which ignores room's gravity, but it still participates normaly in collisions with other objects/fixtures in the physics world? I need this for the fixtures of the left and right pinball flippers.
I need them to move when I touch them. I dont want that room's gravity pulls (around the revolute joint) them in the gravity direction.

Gravity direction is changed a lot (up or down) during the game.

Of course I can neutralize that gravity with some extra amount of joint's motor torque, but I don't want to increase the torque to some insane value just to neutralize gravity which can be pulling up or down.
 
Last edited:
Sounds like you want a kinematic object. You can set the fixture density to 0 to make it unaffected by gravity and other collisions, but things will still collide with it.
 

Tornado

Member
I tried to set density of the flipper to 0, but then motor can not move (rotate) the flipper.
(I'm using physics_joint_revolute_create to create the joint and and physics_joint_enable_motor to rotate it.
 

Tornado

Member
I have to "disable" gravity just for 2 physics objects: left and right flipper. The other physics objects must be influenced by the gravity.
I mean I can do that by setting flippers' fixture density to 0, but if I do it, as I said above, then also the revolute joint motor is not anymore able to rotate the flipper.

I also played with physics_fixture_set_kinematic but didn't help.
 
Last edited:

Jezla

Member
I'm not sure a motor-enabled joint will work with a kinematic object. Do you have an anchor object for your flipper (the joint create function calls for two instances)? Make the anchor object a static object (density 0). The joint will lock the flipper to the anchor's position, preventing it from falling due to gravity, but allowing it to be moved by the joint's motor.
 
M

Misty

Guest
I have to "disable" gravity just for 2 physics objects: left and right flipper. The other physics objects must be influenced by the gravity.
I mean I can do that by setting flippers' fixture density to 0, but if I do it, as I said above, then also the revolute joint motor is not anymore able to rotate the flipper.

I also played with physics_fixture_set_kinematic but didn't help.
Disable gravity for all objects. Set it to zero.

Actually I changed my mind, there is no need for you to disable gravity in a pinball game.
 

Tornado

Member
Thx Jezla, I was hoping you'll read my post as you are physics Guru! :)

Yes, I have an anchor object and the flipper and I make physics_joint_revolute_create(left_hinge, left_flipper, ...) between them.
I tried setting density of the anchor object to zero
physics_fixture_set_density(left_hinge, 0);
but it didn't help. Before I didn't have the density defined for that hinge fixture. I guess zero is the default density anyway, because hinge doesn't move a bit when the ball hits it.

I start to doubt that this is possible to achieve.
 

Jezla

Member
It's possible. I've been playing around the last few minutes with the idea. Here's what I have:

The anchor creates its flipper*, and creates the joint between the two. The motor should pull the flipper down. The flipper control input applies an angular impulse to the flipper that moves it up. Set your minimum and maximum angle for the joint to limit the flipper's travel. You'll have to determine the correct values for the motor torque, motor speed, and angular impulse to get the correct feel, but it's definitely doable.

My test project is really rough, so it's probably not worth sharing, but I think you can figure it out on your own.

* - this means that you will not place flippers in the room, just the anchors. the flippers will be added dynamically.
 
M

Misty

Guest
I don't get it. It sounds like you are creating problems that don't exist.

In real life everything in pinball has gravity. Your flippers should have gravity. Just anchor them to something and put a limit on the motor. Basically what Jezla said.

Unless you have some goal of making unrealistic pinball on purpose or something.
 

Tornado

Member
I have a fully functional game. I'm doing all of that, creating hinge + flipper + joint between them with max and min angle, speed and torque. (I create and place everything dynamically, nothing directly in the room editor)
My pinball is special one, gravity can pull in both directions up and down. It just bums me out that I have to make motor's torque much stronger as normal in order to compensate gravity which can anytime switch the direction. So no matter which direction gravity pulls, I must make torque so strong that when the player moves/rotates the flipper up and down he does't feel any difference in its movement no matter if the gravity pulls up or down.
This is the reason I want to try to decouple the flippers from the influence of the gravity. It works as it is right now, but I have to set the torque to (yes, three million)
But I as wrote, setting flipper's density to 0 makes it immovable to the motor.

Jezla are you suggesting applying an extra impuls to the flipper fixture instead of using physics_joint_enable_motor on the joint? Impulse will work even with density 0?

Thank you all for your time.
 
Last edited:

Jezla

Member
Check your PMs. Apply an impulse to operate the flipper, and use the joint motor to pull it back to it's default position. I think a real pinball machine would use an actuator to move the flipper, and a spring to return it. For our purposes, the joint motor is the spring and the impulse is the actuator.
 

Tornado

Member
Ok, I might try that. (we are on a tight schedule) Right now I have two joints (motors) on one flipper. one motor set to speed x and other to -x. So one is actuator and one is spring. Only one of them is activated at a time. With that I can move flippers up and down - when one motor pulls, the other one releases.
 

Jezla

Member
One other thing, which I'd forgotten. It's possible to change joint properties like angle limits and motor speed, so you could use one joint rather than two, and change the properties when the gravity shifts. Good night and good luck!
 

Tornado

Member
(Yes, I guess I can change speed on the single joint from positive to negative and vice versa.)

I tried your sample project, thank you very much. But the flipper is not decoupled from the gravity. If I increase gravity then that impuls is not enough anymore to move the joint (or it moves it at different speed).
I think we somehow lost the topic here.
The question was how to decouple the flipper from the gravity but still be able to move it when user touch it and release it.
In my game gravity changes directions and strengths, but I want my flipper to hit the ball always with the same "strength".
So I need that flipper to still be inside of the "physics world" but outside of the "gravity world".
That way I could always apply same impuls (or motor speed/torque) to the flipper because gravity direction and strength won't affect the flipper anymore.

Sorry if I couldn't describe it clearly.

THX
 
M

Misty

Guest
How would a pinball game with variable gravity even work? The ball would never return to the flipper! o_O
 

Jezla

Member
I haven't tried this, but couldn't you use phy_angular_velocity variable to control its movement manually?
That would be the only way to move it if the object is set to kinematic. I'm sorry my solution didn't work, but I generally try to find ways within the normal framework of the physics system, so that objects responding to player inputs are manipulated by forces and impulses. I generally recommend kinematic objects be used for objects that move autonomously.
 

Tornado

Member
Setting angular velocity moves it in an constant infinite movement, of course ignoring the physics of the revolute joint.

I abondoned this idea, I`ll just leave it as it is.
Apparently it was stupid idea anywqy.

Thank you all for your help.
 

TheouAegis

Member
Did you try implementing the actual mechanics of a flipper like I posted? lol You never know, maybe the physics engine would make it work right! :eek:
 

Tornado

Member
I already have working flippers with motors for pull and release. The question was just about how to decouple flippers from the gravity, but maybe it was nonsense question anyway. I guess with the motor's huge torque of 300000 N/m (which is my setting) , the gravity value of +-60 is not significantly affecting the flippers.
 
Top