Closed DrFHMNBU closed 12 months ago
the error youre getting is because youre trying to parent te cube to itself. if you want to use multiple textures on one Entity you have to create a texture atlas or use a texture array
This is the atlas: But I have this code:
from ursina import *
import math
app = Ursina()
window.borderless = False
window.exit_button.visible = False
window.fps_counter.enabled = False
window.entity_counter.enabled = False
window.collider_counter.enabled = False
def g(x,y,z):
cube = Entity(model='cube', texture='dirt', position=(x, y, z), scale=(1,3,1))
cube = Entity(parent='cube', model='cube', texture='grass_side', position=(x, y + 1, z), scale=(1.01,1,1.01))
cube = Entity(parent='cube', model='cube', texture='grass', position=(x, y + 1, z), scale=(1,1.01,1))
def getSurface(i,k):
return int((sin(i/5)+cos(k/5))*5)+int((sin(i/25)+cos(k/25))*25)-50
for i in range(20):
for k in range(20):
surface=getSurface(i,k)
g(i,surface,k)
walkspeed=4
rotspeed=90
mouse_sensitivity = Vec2(20, 20)
window.color = color.rgb(0,127,255)
def update():
if held_keys['space'] and mouse.locked == True and mouse.visible == False:
camera.position += (0, time.dt*walkspeed, 0)
if held_keys['x'] and mouse.locked == True and mouse.visible == False:
camera.position += (0,-time.dt*walkspeed, 0)
if held_keys['w'] and mouse.locked == True and mouse.visible == False:
camera.position += (math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed)
if held_keys['s'] and mouse.locked == True and mouse.visible == False:
camera.position -= (math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed)
if held_keys['a'] and mouse.locked == True and mouse.visible == False:
camera.position -= (math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, -math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed)
if held_keys['d'] and mouse.locked == True and mouse.visible == False:
camera.position += (math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, -math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed)
if mouse.left:
mouse.locked = True
mouse.visible = False
if held_keys['escape']:
mouse.locked = False
mouse.visible = True
if mouse.locked == True and mouse.visible == False:
camera.rotation_y += mouse.velocity[0] * mouse_sensitivity[1]
camera.rotation_x -= mouse.velocity[1] * mouse_sensitivity[0]
camera.rotation_x = clamp(camera.rotation_x, -90, 90)
app.run()
How to use it? With texture.load("atlas_grass_cube")
?:
you need to make your own cube model
This is the function used to generate the cubes:
But with transforming into it crashes:
This is the error log:
I want to render 6 materials for each face of the cube, so... any solution? Thanks anyway.