0

I'm recently developing a ursina app, and I have a question. Whenever I get the player position, it comes in a vec3 format, so when i call it in the update() function, I get an error.:

  File "c:\Users\tee_c\Projects\PGAU_vm\Applications@\3d\parkour\creative.py", line 43, in update
    if tuple(Pposition)[1] <= tuple(Solid_air.position)[1]+2:
TypeError: 'property' object is not iterable

So I want to convert the vec3 to a tuple, but I haven't found any answers.If you need, Here is my code.:

import ursina
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from ursina.shaders import lit_with_shadows_shader
Entity.default_shader = lit_with_shadows_shader
game=Ursina()
class Voxel(Button):
    def __init__(self,position):
        super().__init__(
            parent=scene,
            position=position,
            model='cube',
            origin_y=0.5,
            texture="white_cube",
            color=color.blue,
            highlight_color=color.green,
        )
    def input(self,key):
        if self.hovered:
            if key=='right mouse down':
                block=Voxel(position=self.position+mouse.normal)
            if key=='left mouse down':
                destroy(self)
class Solid_air(Button):
    def __init__(self, position):
        super().__init__(
            parent=scene,
            position=position,
            model='cube',
            origin_y=1,
            texture="white_cube",
            color=color.white,
            highlight_color=color.red,
        )
for a in range(31):
    for b in range(31):
        block = Voxel(position=(a, 1, b))
        block = Solid_air(position=(a, -1, b))
player = FirstPersonController()
def update():
    Pposition=player.position
    if tuple(Pposition)[1] <= tuple(Solid_air.position)[1]+2:
        tuple(Pposition)[1]+=1
game.run()
E_net4
  • 27,810
  • 13
  • 101
  • 139

1 Answers1

0

Solid_air is a class, not an Entity instance. So position is a property, not a Vec3. You want to get .position on one of the blocks you created, not the class itself.

pokepetter
  • 1,383
  • 5
  • 8