1

I am new to game development. I am trying to start high and make a 3D RPG. I know the road is not gonna be easy. That is why i decided to use Ursina and python to make my game.

However i wanna add a cutscene showing a Backstory. I have the video in mp4 format but i cannot seem to know how to play it inside the game with Ursina.

Anyhelp will be much appreciated. (Side question : do you think Ursina is good for a beginner in 3D gaming? If i want to publish my game on my website, isn't it better for me to learn javascript ? I read about Unity but it is too big to download for a little side project)

1
  • As for your side question, Ursina has many things built in but will still require you to do coding and have a good understanding of various 3D concepts. It all depends on your background. You don't have to learn JavaScript to publish your game. Commented Jul 9, 2021 at 5:50

3 Answers 3

3

You can set the video as a texture of any element. You'll want to fix it to the UI using its parent attribute and you have to load the sound separately from the same file (as described in the Panda3D documentation).

from ursina import *

app = Ursina()

video = 'video.mp4'
video_player = Entity(model='quad', parent=camera.ui, scale=(1.5, 1), texture=video)
video_sound = loader.loadSfx(video)
video_player.texture.synchronizeTo(video_sound)
video_sound.play()

app.run()

The above code assumes that the video file is in the same folder as the Python script.

2
  • Can we loop the video? Commented Jan 29 at 18:09
  • 1
    @ShashvatKumar sure, just set video_sound.setLoop(True) Commented Feb 1 at 14:50
2

From Entity Basics in the documentation:

e4 = Entity(model='cube', texture='movie_name.mp4') # set video texture

-1

Well, I don't think there is a way to do that. the closest thing you can do to that is having a folder filled with all the frames of your video in .png or .jpg files, then adding a quad to the world and changing the texture of it to the next frame every fraction of a second depending on the framerate. this, however would make your computer l a g. trust me, I've tried it. it would probably be better to have a separate window with some sort of module that plays .mp4 files for playing the file. In other words, there is no feasible way to do that.

2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Oct 5, 2021 at 15:26
  • It is possible and feasible in most of the cases. Commented Jan 29 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.