meshcraft - place blocks in different directions
Using mouse normal and bte collider
-
add collider -mining_system.py
bte = Entity(model='cube',color=color.rgba(1,1,0,0.4), collider="box")# Add collider -
Change checkBuild function to use mouse normal -building_system.py
from ursina import Vec3, floor, mouse#import mouse
from mining_system import bte#import bte
def checkBuild(_td):
_bsite = bte.position
_bsite += Vec3(0,-0.5,0)
if mouse.normal:# Add mouse normal addition
_bsite.x += round(mouse.normal.x)
_bsite.y += round(mouse.normal.y)
_bsite.z += round(mouse.normal.z)
else:
_bsite.y += 1
x = floor(_bsite.x)
y = floor(_bsite.y)
z = floor(_bsite.z)
if _td.get((x,y,z))!='g' and _td.get((x,y,z))!=None:
print("Can't build here, sorry :(")
return None
return Vec3(x,y,z)
- Change checkBuild function call
-mesh_terrain.py
bsite = checkBuild(this.td)#Change f call#str58
Point with the red dot on the highlighted block and click to place
-----------Red dot height fix------------
After the subject initiation
subject.height = 1.86
subject.camera_pivot.y = 1.86 # = Player Height
it is the player controller code , it needs customization for meshcraft needs
we can make our own first person controller using default as a base later
to clean-up the main function
PS
Thank you for this fun tutorial! :)
Hello, sorry my bad, i think
subject.height = 1.86 in your code will break step up thing
but camera height can still be changed
Also collision on bte will break step up too We can delete foot ray in the firstpersoncontroller or without collision make additional second highlight , what visible if there is a block in the shell around it (in directional axis positions around) (second highlight)
O, and one idea, (i add it as a issue if ill make something later) We can put blocks in the air with a little bit of code refactoring We can create creatures what stand on the moving clouds or just jump on created blocks We also can make living 'subset' Like a snake, consisting of the blocks, it moves blocks positions in the space And i like your idea of speed building,
Thanks