Im trying to make an sandbox game where you can place blocks but the texture for the Block does not appear and neither does the block. Before i added the second def add_box_wood it all worked just fine.
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
player = FirstPersonController()
Sky()
boxes = []
def add_box(position):
boxes.append(
Button(
parent=scene,
model="cube",
origin=0.5,
color="green",
position=position,
texture="grass"
)
)
def add_box_wood(position):
boxes.append(
Button(
parent=scene,
model="cube",
origin=0.5,
color="brown",
position=position,
texture='texture/wood.jpg'
)
)
for x in range(20):
for y in range(20):
add_box( (x, -4, y) )
def input(key):
for box in boxes:
if box.hovered:
if key == "right mouse down":
add_box_wood(box.position + mouse.normal)
if key == "left mouse down":
boxes.remove(box)
destroy(box)
app.run()
I tried to just color it brown but that didnt work.
I noticed few issues:
wood.pngimage to the script folderfrom ursina import *. It's a bad practiceHere is the fixed code:
Output: