0

I started using Ursina engine not long ago, I started with making a small fps game but the gun wouldn't load, and the sound and shooting spark animation wouldn't show

Here is my code:

from ursina import *
from random import uniform
from ursina.prefabs.first_person_controller import FirstPersonController

def input(key):
    if key=="left mouse down":
        Audio("assets/laser_sound.wav")
        Animation("assets/spark", parent=camera.ui, fps=5, scale=.1, position=(.19, -.03), loop=False)

app=Ursina()

Sky()
player=FirstPersonController(y=2, origin_y=-.5)
ground=Entity(model='plane', scale=(100, 1, 100), color=color.lime, texture="white_cube",
    texture_scale=(100, 100), collider='box')

wall_1=Entity(model="cube", collider="box", position=(-8, 0, 0), scale=(8, 5, 1), rotation=(0, 0, 0),
    texture="brick", texture_scale=(5, 5), color=color.rgb(255, 128, 0))
wall_2=duplicate(wall_1, z=5)
wall_3=duplicate(wall_1, z=10)
wall_4=Entity(model='cube', collider='box', position=(-15, 0, 10), scale=(1, 5, 20), rotation=(0, 0, 0), texture='brick', texture_scale=(5, 5), color=color.rgb(255, 128, 0))

gun=Entity(model='assets/gun.obj', parent=camera.ui, scale=.08, color=color.gold, position=(.3, -.2), rotation=(-5, -10, -10))

app.run()

I tried downloading multiple things like pyaudio and many others including ursina

N3bu1a
  • 1
  • my problem is with line 23: gun=Entity(model='assets/gun.obj', parent=camera.ui, scale=.08, color=color.gold, position=(.3, -.2), rotation=(-5, -10, -10)) – N3bu1a Dec 10 '22 at 15:52
  • You should write the output. I guess it may be some wrong path, but without the console output I can't help – Lixt Dec 11 '22 at 13:17
  • You should put an image of your asset folder content – Lixt Dec 15 '22 at 14:15

1 Answers1

-1

ursina is built on panda3D so where you put things like .wav and .obj won't work because panda3D/ursina automatically adds the .wav and or .obj to the end of the path so instead of

gun=Entity(model='assets/gun.obj', parent=camera.ui, scale=.08, color=color.gold, position=(.3, -.2), rotation=(-5, -10, -10))

do

gun=Entity(model='assets/gun', parent=camera.ui, scale=.08, color=color.gold, position=(.3, -.2), rotation=(-5, -10, -10))

and same with the audio instead of

Audio("assets/laser_sound.wav")

do

Audio("assets/laser_sound")

so it should look like:

from ursina import *
from random import uniform
from ursina.prefabs.first_person_controller import FirstPersonController

def input(key):
    if key=="left mouse down":
        Audio("assets/laser_sound")
        Animation("assets/spark", parent=camera.ui, fps=5, scale=.1, position=(.19, -.03), loop=False)

app=Ursina()

Sky()
player=FirstPersonController(y=2, origin_y=-.5)
ground=Entity(model='plane', scale=(100, 1, 100), color=color.lime, texture="white_cube",
    texture_scale=(100, 100), collider='box')

wall_1=Entity(model="cube", collider="box", position=(-8, 0, 0), scale=(8, 5, 1), rotation=(0, 0, 0),
    texture="brick", texture_scale=(5, 5), color=color.rgb(255, 128, 0))
wall_2=duplicate(wall_1, z=5)
wall_3=duplicate(wall_1, z=10)
wall_4=Entity(model='cube', collider='box', position=(-15, 0, 10), scale=(1, 5, 20), rotation=(0, 0, 0), texture='brick', texture_scale=(5, 5), color=color.rgb(255, 128, 0))

gun=Entity(model='assets/gun', parent=camera.ui, scale=.08, color=color.gold, position=(.3, -.2), rotation=(-5, -10, -10))

app.run()
  • even doing that still ursina provides ```missing model: TV```, however this issue i couldn't resolve it unless using ```.obj``` with adding its texture – Jawad Apr 08 '23 at 03:00