Comments (3)
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
from ursina.
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")
?:
from ursina.
you need to make your own cube model
from ursina.
Related Issues (20)
- "Monitor not found" in Debian BookWorm linux HOT 1
- Undocumented settings.py behaviour HOT 2
- Text.default_font does not work for dynamic fonts HOT 1
- AttributeError when loading textures -> load_texture() HOT 1
- How to animate 3D character using shape keys HOT 1
- Conversation is broken HOT 2
- May bad terrain generation... HOT 1
- How to increase the performance with this python script?: HOT 1
- i dont have a rotation_gizmo_model.ursinamesh HOT 1
- Render distance performance-oriented HOT 1
- ValueError when running `particle_system.py` HOT 1
- I tried to merge all cubes in Mesh() function, but it didnt worked for me... HOT 1
- The discord link on reddit is down. HOT 1
- ERROR: Cannot install ursina==0.2, ursina==0.3..........ursina==6.1.1 and ursina==6.1.2 because these package versions have conflicting dependencies. HOT 2
- macOS missing dependency: ModuleNotFoundError: No module named 'screeninfo' HOT 3
- I used 'parent=terrain' and it didnt still worked for me for increase the performance: HOT 1
- Typo on documentation Entity Basics - Other Magic Functions HOT 2
- InputField should have a "wrap text" option
- Ursina cannot open monitor under Docker
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ursina.