So im new to ursina and listen to a lot of youtube how to's and alot of github, doc for ursina, reddit, etc. before i got into it. well i decided to get into the actual coding part and pick this code and i wanted to see if there was a way for two or more classes to interact with each other for example collision, because i was kinda confuse on how you give attributes to the objects in the game like health, status etc. i tried using the getattr() but it didnt work. in ursina is interaction between classes different or is giving the attributes to objects different? heres the code:
from ursina import *
app = Ursina()
EditorCamera()
class Players():
def __init__(self):
super.__init__()
self.player = Entity(model='cube', color=color.orange, collider='box', origin_y=-.5)
class Triggerbox():
def __init__(self):
super.__init__()
self.trigger_box = Entity(model='wireframe_cube', color=color.gray, scale=2, collider='box', position=Vec3(1,0,2), origin_y=-.5)
def update():
player.z += (held_keys['w'] - held_keys['s']) * time.dt * 6
player.x += (held_keys['d'] - held_keys['a']) * time.dt * 6
if player.intersects(trigger_box).hit:
trigger_box.color = color.lime
print('player is inside trigger box')
else:
trigger_box.color = color.gray
app.run()