Using the Ursina module

Hello! This python module:

called ursina is created in panda3d. I started making a game in it, and was wondering, because ursina is made in panda3d, will it be right to put the game in the panda3d community as it eventually is panda3d?

First you should worry about finishing the game. Second, why not use just panda? If you run into issues with Ursina, it will be probably harder to get some sort of help if people here dont use it.

If you’re asking whether it’s okay to show it off on this forum then, while I’m no mod and thus don’t speak with authority, I don’t see why not. As you say, while it would be using a third-party framework/engine, underneath that it uses Panda, and thus it’s potentially of interest to the community here.

If you’re asking whether it’s okay to ask for help with it here, then I’d say that it’s likely okay to ask for help with Panda-specific things. However, help with Ursina-specific things would likely be better asked in an Ursina community, or of the Ursina devs, I think.


I can’t use panda because there is a feature in Ursina that I can’t seem to recreate in panda. I read the source code, but still, I can’t recreate it.

If you don’t mind a tangent for curiosity, what is that feature?

1 Like

This is the one:

EDIT: It is used to determine which side of an object the mouse has clicked, and it is useful for making games.

But Panda’s internal collision system does provide collision-normals, as I recall.

But in GitHub when I click on self.collision.normal, it redirects me to the same thing I have shared the link of, as if it is a recursion.


Is it of a CollisionNode or a CollisionSolid?

Neither. It’s provided by the CollisionEntry class, I believe–the class of which instances are provided in collision -events and -queues.

So, for example:

# Presume that we've set up a CollisionHandlerQueue to pick up events

if self.handler.getNumEntries() > 0:
    entry = self.handler.getEntry(0)
    collisionNormal = entry.getSurfaceNormal(render)


# Presume that we've set up a CollisionHandlerEvent, and
# registered a collision-event to call the method below

def someCollisionOrOther(self, entry):
    collisionNormal = entry.getSurfaceNormal(render)

Does it do what ursina.mouse.normal does?

I’ve never used Ursina, so I have little idea, I’m afraid. What does ursina.mouse.normal do?

Run You will see that we can place blocks like minecraft. The source code just creates a new block every time a block is clicked by doing clicked_block.position + mouse.normal (mouse is global). Then it creates a new block in the place the mouse has clicked (at the correct side, so if we click on the right of the block there is a new block at the right and so on.)

So, if I’m understanding you correctly, it detects the point under the mouse and then provides the surface normal? That’s quite doable in Panda, I believe.

It would call for some implementation–something along these lines, I believe:

  • Create a ray and a queue-handler
  • When the user clicks (or under whatever condition you prefer, e.g. every frame):
    • Update the ray’s position and orientation to reflect the mouse-cursor, using “setFromLens”
    • Traverse the scene-graph
    • Check the queue for entries
      • If there is more than one:
        • Sort the entries
        • Take the first entry (which, after sorting, should be the closest).
          • From this, copy the relevant data (e.g. surface-position and surface-normal) to your own variables, if called for.

The only caveat is the question of objects that have no collision-nodes attached, should there be any. You could have your ray detect all visible geometry, but this may have performance implications.

Actually second as the camera also has a collision solid.

Will try.

EDIT: So collision.normal returns a Vec3, right?

1 Like

That’s fair–although note that this is one case in which bitmasks can help, allowing you to prevent the ray from colliding with the camera’s collision-object.

Do you mean “CollisionEntry.getSurfaceNormal()”? If so, then I believe that that’s right, yes.

Yeah, I could do that, I would set the ray’s bitmask to only the object while the camera’s to the objects, but not the ray.

Yes. OK. Will try (I am tired of typing will try again and again :slight_smile: )

1 Like

Exactly, yes. :slight_smile:

That’s fair! I can understand being tired, I do believe! ^^;

If it is unclear, it means that it gets the side of the clicked object (The ursina one). So like the game minecraft, if we right-click the left of a block, a new block appears on the left whereas we click up, there is a new block above the block and so on.

That sounds like it likely involves just what I said, indeed.

(Plus more logic for creating a block, aligning it with the centre of the selected one, etc. But that’s likely specific to the Minecraft-game, I imagine, rather than being the general functionality of that “mouse.normal” feature.)