player.py: from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from bullet import Bullet
class Player:
def __init__(self):
self.gravity = 0.98
self.player = FirstPersonController()
self.gravity = 0.8
self.player.gravity = self.gravity
self.rotation_speed = 100 # Adjust rotation speed as needed
self.target_rotation = 0
self.current_rotation = 0
def update(self):
self.player.y += self.player.gravity * time.dt
hit_info = self.player.intersects()
if hit_info.hit:
self.player.position = hit_info.point
if held_keys['q']:
self.target_rotation = -45
elif held_keys['e']:
self.target_rotation = 45
else:
self.target_rotation = 0
# Smoothly interpolate rotation
self.current_rotation = lerp(self.current_rotation, self.target_rotation, self.rotation_speed * time.dt)
self.player.camera_pivot.rotation_z = self.current_rotation
if not Bullet:
Bullet.update()
if held_keys['left mouse']:
Bullet(self.player.position,self.player.rotation) bullet.py: from ursina import *
class Bullet:
def __init__(self,pos,rot):
self.bullet = Entity(model='cube',collider='box')
self.bullet.scale = Vec3(0.25,0.25,0.25)
self.bullet.position = pos
self.bullet.rotation = rot
def update(self):
self.bullet.z += 1 * time.dt main.py: from ursina import *
from ursina.shaders import lit_with_shadows_shader
from ursina.prefabs.first_person_controller import FirstPersonController
from player import Player
app = Ursina()
bullets = 0
blooddrop1 = Sprite(texture='resources/blooddrop1')
blooddrop1.position = Vec3(0,0.1,2)
blooddrop1.rotation = Vec3(90,0,0)
player = Player()
floor = Entity(model='plane', scale=10, color=color.gray,shader=lit_with_shadows_shader, collider='box')
cube = Entity(model='cube', y=1, shader=lit_with_shadows_shader, collider='box')
cube.disable()
pivot = Entity()
gun = Entity(parent=player.player,model='resources/gunUpload.obj',scale=0.025,y=1.75,x=0.25,z=0.25)
bullets_text = Text(text=f'Bulllets: {bullets}')
bullets_text.position = Vec2(0.25,0.25)
DirectionalLight(parent=pivot, y=2, z=3, shadows=True, rotation=(45, -45, 45))
#SpotLight(parent=pivot,y=player.player.Y,x=player.player.X,shadows=True,rotation=player.player.rotation)
app.run() Сделайте нормальную систему стрельбы, я уже устал, вечер, башка вообще не варит
from ursina.prefabs.first_person_controller import FirstPersonController
from bullet import Bullet
class Player:
def __init__(self):
self.gravity = 0.98
self.player = FirstPersonController()
self.gravity = 0.8
self.player.gravity = self.gravity
self.rotation_speed = 100 # Adjust rotation speed as needed
self.target_rotation = 0
self.current_rotation = 0
def update(self):
self.player.y += self.player.gravity * time.dt
hit_info = self.player.intersects()
if hit_info.hit:
self.player.position = hit_info.point
if held_keys['q']:
self.target_rotation = -45
elif held_keys['e']:
self.target_rotation = 45
else:
self.target_rotation = 0
# Smoothly interpolate rotation
self.current_rotation = lerp(self.current_rotation, self.target_rotation, self.rotation_speed * time.dt)
self.player.camera_pivot.rotation_z = self.current_rotation
if not Bullet:
Bullet.update()
if held_keys['left mouse']:
Bullet(self.player.position,self.player.rotation) bullet.py: from ursina import *
class Bullet:
def __init__(self,pos,rot):
self.bullet = Entity(model='cube',collider='box')
self.bullet.scale = Vec3(0.25,0.25,0.25)
self.bullet.position = pos
self.bullet.rotation = rot
def update(self):
self.bullet.z += 1 * time.dt main.py: from ursina import *
from ursina.shaders import lit_with_shadows_shader
from ursina.prefabs.first_person_controller import FirstPersonController
from player import Player
app = Ursina()
bullets = 0
blooddrop1 = Sprite(texture='resources/blooddrop1')
blooddrop1.position = Vec3(0,0.1,2)
blooddrop1.rotation = Vec3(90,0,0)
player = Player()
floor = Entity(model='plane', scale=10, color=color.gray,shader=lit_with_shadows_shader, collider='box')
cube = Entity(model='cube', y=1, shader=lit_with_shadows_shader, collider='box')
cube.disable()
pivot = Entity()
gun = Entity(parent=player.player,model='resources/gunUpload.obj',scale=0.025,y=1.75,x=0.25,z=0.25)
bullets_text = Text(text=f'Bulllets: {bullets}')
bullets_text.position = Vec2(0.25,0.25)
DirectionalLight(parent=pivot, y=2, z=3, shadows=True, rotation=(45, -45, 45))
#SpotLight(parent=pivot,y=player.player.Y,x=player.player.X,shadows=True,rotation=player.player.rotation)
app.run() Сделайте нормальную систему стрельбы, я уже устал, вечер, башка вообще не варит