-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
27 lines (20 loc) · 901 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from ursina import *
app = Ursina()
class Player(Entity):
def update(self):
self.direction = Vec3(
self.forward * (held_keys['w'] - held_keys['s'])
+ self.right * (held_keys['d'] - held_keys['a'])
).normalized() # get the direction we're trying to walk in.
# the ray should start slightly up from the ground so we can walk up slopes or walk over small objects.
origin = self.world_position + (self.up*.5)
hit_info = raycast(origin, self.direction, ignore=(
self,), distance=.5, debug=False)
if not hit_info.hit:
self.position += self.direction * 5 * time.dt
Player(model='cube', origin_y=-.5, color=color.orange)
wall_left = Entity(model='cube', collider='box', scale_y=3,
origin_y=-.5, color=color.azure, x=-4)
wall_right = duplicate(wall_left, x=4)
camera.y = 2
app.run()