Frequently Asked Questions

How do I update ursina?

How should I structure my project?

    Like this:
project_folder/ # create a new folder for each project enemies.py level.py main.py # the starting script player.py player_sprite.png textures/ # assets can be placed alongside the scripts or in a folder below enemy_1.png enemy_2.png

How do I move the camera?

The camera is an Entity, so you can move and rotate it just like everything else:
camera.position = Vec3(1,1,0)

Why should I use Python for game development. Isn't it slow?

Not really. The most performance critical part are written in C++ or shader code.
Python can make you more productive as a developer and thus make it easier
to structure your project in a good way, rather than micro-optimize.

How do I call a function with a delay?

invoke(some_function, arg1, kwarg1='some kwarg', delay=2)

How do I add lights?

If all you want are some simple lights to make 3D shapes look more interesting,
look at the program 'lights.py' in the samples folder.  For anything more complicated,
you are on your own. The DirectionalLight has shadows too, but it's recommended to use the
lit_with_shadows_shader on entities. The shadow area will be calculated based on the scene bounds,
so keep that in mind when isinstanciation the light.

How can I use panda3d alongside ursina?

What you need to know is that Entity is a NodePath and Ursina is a ShowBase.
You can also write custom shaders, see panda3d's shader documentation for that.

How do I detect collisions?

One way is with raycasts. They can hit anything with a collider.


There's also intersects(), which use the entity's collider and check if it intersects other colliders.
Like raycast(), it also returns a HitInfo.

Here's an example from the FirstPersonController:

# cast a ray from the player position in the walk direction. # only move forward if it doesn't hit anything. origin = self.world_position + (self.up*.5) + (self.direction/2) ray = raycast(origin , self.direction, ignore=[self,], distance=.25, debug=False) if not ray.hit: self.position += self.direction * self.speed * time.dt

How do I make a character animate?

You have two options here. The first one is using .glft files and panda3d's Actor:

from ursina import * from direct.actor.Actor import Actor app = Ursina() entity = Entity() #animations are stored within the file actor = Actor("filename.gltf") actor.reparent_to(entity) actor.play("animation_name") app.run()

See the panda3d documentation for more info.

The second option is to use FrameAnimation3d. For that you need a sequence of models that can be loaded by ursina.
So if you have some frames named run_cycle_000.obj, run_cycle_001.obj, run_cycle_002.obj and so on,
you can load it like this: