Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Class Object not working as expected in Ursina

I have a class named startPlatform in Python. I am using the ursina engine. When I call it, it gives me an error:

Traceback (most recent call last):

File "C:/Users/eshan/OneDrive/Desktop/ursina-platformer-maker/main.py", line 29, in <module>`
    StartPlatform(position = (10, 5, 8))
  File "C:/Users/eshan/OneDrive/Desktop/ursina-platformer-maker/main.py", line 17, in __init__
    super().__init__(
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

The argument are correct, and I don’t know what’s happening. Here’s my Code:

from ursina import *
from ursina.prefabs.sky import Sky
from ursina.shaders import basic_lighting_shader

app = Ursina()
editor = EditorCamera()

def input(key):
    if held_keys["q"]:
        quit()

class StartPlatform():
    def __init__(self, position = (0, 0, 0)):
        super().__init__(
            parent = scene,
            model = "cube",
            position = position,
            scale = (5, 2, 6),
            collider = "mesh",
            shader = basic_lighting_shader,
            texture = "white_cube",
            color = color.lime
        )

Sky()
StartPlatform(position = (10, 5, 8))
app.run()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

StartPlatform does not inherit Entity, which I assume is what you want it to be.

class StartPlatform():

Should be:

class StartPlatform(Entity):
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading