Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off gravity for rigid body #25

Open
freQuensy23-coder opened this issue Jan 12, 2023 · 3 comments
Open

Turn off gravity for rigid body #25

freQuensy23-coder opened this issue Jan 12, 2023 · 3 comments

Comments

@freQuensy23-coder
Copy link

I want to turn off gravity for one scene, but methods from pymunk docs does not works.
Firstly I tryied to change scene space gravity paramether in construct method:

def construct(self):
        self.space.gravity = 0, 0```

But it doesn't help
Then i tried to override init method for Space scene class, but it did not bring any result

    def __init__(self, renderer=None, **kwargs):
        self.space = Space(gravity=(0, 0))
        super().__init__(renderer=renderer, **kwargs)

Full code:

from manim import *
from manim_physics import *

class FirstScene(SpaceScene):   
    def __init__(self, renderer=None, **kwargs):
        self.space = Space(gravity=(0, 0))
        super().__init__(renderer=renderer, **kwargs)

    def construct(self):
        self.space.gravity = 0, 0
        c1 = Circle(color="red").shift(2* LEFT)
        c2 = Circle(color="blue").shift(RIGHT)
        self.make_rigid_body(c1, c2)
        c1.body.velocity = (1, 0)
        self.wait(10)
@icedcoffeeee
Copy link
Collaborator

The GRAVITY attribute can be set like so:

class FirstScene(SpaceScene):
    GRAVITY = (0, 0)

    def construct(self):
        c1 = Circle(color="red").shift(2 * LEFT)
        c2 = Circle(color="blue").shift(RIGHT)
        self.make_rigid_body(c1, c2)
        c1.body.velocity = (1, 0)
        self.wait(10)

@freQuensy23-coder
Copy link
Author

freQuensy23-coder commented Jan 14, 2023

It does not help. When you run your code, you get this result
video

@icedcoffeeee
Copy link
Collaborator

Interesting, I can't reproduce this. Can you provide your manim version and OS information? Just for clarity: can you confirm you've done the following steps:

  1. The python file only contains:
from manim import *
from manim_physics import *

class FirstScene(SpaceScene):
    GRAVITY = (0, 0)

    def construct(self):
        c1 = Circle(color="red").shift(2 * LEFT)
        c2 = Circle(color="blue").shift(RIGHT)
        self.make_rigid_body(c1, c2)
        c1.body.velocity = (1, 0)
        self.wait(10)
  1. Save the file.
  2. In the terminal, run:
manim file_name.py -pql

@icedcoffeeee icedcoffeeee reopened this Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants