Contribution ideas - more GAME samples!

Updates!! After my initial post here asking for interest in more Panda3D samples, many folks have contributed great ideas and code to this effort. I’ll update this message to contain all these great submissions here as they roll in. (Great work folks! Keep it coming!)


New samples created by the community here! (Updated as we build them):

Community made demos / with source to look at for inspiration/code ideas:

Resources for helping folks create samples:

Works in progress, being launched from discussion in this thread!


Original message:

Hi folks! First time post here, though I’ve read a lot as I’ve been diving into Panda3D lately. I’m a longtime professional software dev - and big Unreal Engine 4 and Unity user, but really like the simplicity of Panda3D (and Python!) so would like to start some Panda3D development.

I thought that while I learn and ramp up to also contribute back - with some community help I really think Panda could catch on and be much, much more popular as an engine. Speaking as a Unity/Unreal dev here.

My first thought - the samples that come with Panda could really be improved. ‘Roaming Ralph’ is the closest that I could find that would work as a foundation for a real game, but would really like to improve on it. Here are my ideas for samples to build:

  • A new 3rd person sample, based on Roaming Ralph

    • Better controls, standard WASD plus mouse for camera zoom support. The controls are very strange. I would add mousewheel to zoom camera
    • Better camera management, collides with environment and auto-zooms in small spaces, as with most 3rd person games today
    • Better physics, Ralph sticks on everything on my machine and gets stuck.
    • Jumping
  • Multiplayer samples based on the previous 3rd person sample, very simple movement, chat, trigger some animations

  • Simple procedural world with terrain / trees built on the 3rd person features as well

  • Sample or tutorial showing how to go from Mixamo-type animated character to Blender, to Panda, for folks that don’t have modelling skills. And the lack of good media for Panda would be helped here.

Let me know more ideas, but this is where I’d like to start!

Thanks!

-Sal

2 Likes

Greetings and salutations, and welcome to the forum! :slight_smile:

I do think that some new samples might be a good idea indeed.

That said, I’m not sure about the idea of so expanding and refining Roaming Ralph: while I think that some refinements might indeed be beneficial, I do worry about making the sample too complex.

It is, after all, intended for new users only just starting out with Panda. (And indeed, in some cases, just starting out with Python and game-dev.)

(The camera-work in particular might over-complicate the sample, I fear.)

Multiplayer samples do seem like a good idea, and a solid demonstration of how to do that with the engine could be an excellent addition, I think! Similarly demonstrations of procedural worlds and the character-pipeline tutorial that you suggest. :slight_smile:

All that said, let me mention that I have a “Beginner’s Tutorial” available: while it doesn’t have nearly all that you suggest, it does cover a fair chunk of the basics, produces a full, functional–if simple–game, and runs from the fundamentals of using the engine to building a distributable.

You should find it here:

Hi, welcome, we’re happy to have you here!

You’re definitely right that the samples aren’t representative of what Panda3D can do, and that even some minor love could go a long way. I welcome this effort to make some improved samples. :slight_smile:

As @Thaumaturge rightly points out, the samples are generally meant to illustrate a particular feature of Panda3D without unnecessary extras. But, the Roaming Ralph sample is often used by people to learn how to put together the parts for a third-person controlled character game, so I think it could definitely use some love. It’s not even using best practices for how to use things like the collision system.

I do agree: Roaming Ralph is perhaps the most salient of the samples, being the closest to a full game. And yet it has a number of issues, and some practices that could perhaps misinform new developers. As a result, it could very much use some reworking and polish, I do think!

[edit] One idea might be to have both “samples” and “showcases”: The former would be what we currently have, being small, easily-digested examples of how things might be done in the engine. The latter would be things intended to show the capabilities of the engine, even if that makes for a more-complicated project.

There is the risk of new developers jumping straight to the more-impressive “showcase” pieces, and finding themselves out of their depths, however.

I actually did stumble on this! Its a great tutorial, thanks for putting this together.

1 Like

rdb, sounds great. Do you have any pointers or samples to how you envision the collision should work? I’ll be happy to incorporate that. Still new to Panda3d myself, so this will help me get up to speed as well.

Looking forward to hacking on this. Side note - in the back of my mind I keep thinking of a scenario like in Unreal4 where, there are samples for each basic game type (1st person, 3rd person, etc) and it’s really easy to use those as starting points for your own games. Although they do minimal things. I think this would be where I’d like to go here as well.

I’ll post when I have some work to show. Thanks!

1 Like

I like your idea in theory, but I am wary of making Panda3D opinionated like Unreal 4 is. Panda3D is never going to be “really easy to use” unless we change it fundamentally, like I suppose the Ursina project which I have never used.

More or more modern example programs would be nice to have. I do not particularly like the idea of template standards for “game types” as that removes a lot of the benefits of an engine which isn’t super opinionated or unduly optimized for a specific thing. If this were ever to happen to Panda3D I would fork it and maintain the code first tradition.

This is of course just speculation and I’m not against modernizing the examples, as some of them are outdated.

I can add that adding new code as an example is not a problem. The problem is the lack of modern models and good animations.

Ursina is a good example of how one could wrap some of the Panda3D API to improve its simplicity, for sure. Game engine design is a very tricky thing, you have super experienced devs that prefer to do everything in native, C or C++, some folks want a purely graphical tool. Myself personally, I like the in-between, ability to write C when needed, and a graphical tool ‘if needed’ but much prefer to script in Python for the majority. I feel like assembling a scene graph and processing events can all be done outside the game loop and get great performance. Panda3d seem perfect fit here! And if we’d like to simplify further we could add some layers like Ursina did (while not preventing folks to use the more core APIs as well)

I look at game engine samples more like ‘Documentation’, so for example a 3rd person sample doesn’t actually change the game engine to be ‘opinionated’ but does ‘document’ how one could approach the problem, if that makes sense. You’re not prevented from using underlying APIs. Of course for lazy folks like myself, I tend to just copy / paste those samples and modify as needed - which I think really helps folks get up to speed quickly.

In the case of Panda3d it looks like it’s completely doable to have high-quality, copy/paste examples of how to do very common things (3rd person, 1st person games, etc.) but it just takes some of us to step up and write some Python, hence my idea to contribute here!

Thanks for all the feedback. Happy to hear more ideas!

-Sal

Completely agree here. In my original message I mentioned ‘Mixamo’, but there seems to be a lot of good sources of professional 3d assets - and the tooling is there (Blender plugins, etc) to piece these together, so I think some examples of how to tie all those together (with a sample app!) is a great idea! For example, have some folders with ‘raw’ assets, maybe pulled from a free 3d repository like Mixamo or other, then another folder that has the same assets ‘post conversion’, with docs on how it was done. Then finally a sample app that loads all those assets and shows a simple game. It sounds like a lot of steps but really, every game dev needs to go through this process so I think makes sense to have this as a fundamental parts of Panda’s code samples.

Love to hear more ideas here.

-Sal

I think it is totally doable to make a more complete demo of a third-person or first-person game. Especially if it looks good it will give people a good impression of what they can do, as well as some reference for how they can structure a more complicated game (which the current samples completely fail to do, because they attempt to be simple).

I don’t think that should necessarily take us in the direction of “template games” that people should build off of (some undoubtedly will, but that applies to any example code). Nor do I think that it should make Panda more opinionated, as long as we’re not actively steering people towards doing things a certain way or telling people that a particular sample is the only way of doing things.

Again, to the question of the approach, it is worth understanding that the example will be taken as a reference. And it will be used in the design of the game for beginners. But there are several ways to achieve the goal. For example, collision detection, physics: ODE, Bullet. What can confidently advice from this?

I think we need all the options. Just minimal code, some aspects of the mechanics. For example, detecting an intersection point.

Then the user will be able to build more complete mechanics from such short codes.

The problem of the correct approach has become obvious to the panda, there are problematic examples like this, moving actor:

https://docs.panda3d.org/1.10/python/introduction/tutorial/using-intervals-to-move-the-panda

Which is perceived as a standard for beginners, although from an experienced point of view, this example is not suitable for this.

I suggest having many examples and short ones like this.

"""
Original code : http://www.panda3d.org/phpbb2/viewtopic.php?t=4806
Author: ThomasEgi
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import BitMask32, CollisionTraverser, CollisionNode, CollisionRay, CollisionHandlerQueue

base = ShowBase()

terrain = loader.loadModel("colltest")
terrain.reparentTo(render)
terrain.setCollideMask(BitMask32.bit(1))

player = loader.loadModel("panda")
player.setScale(.18)
player.reparentTo(terrain)

collTrav = CollisionTraverser()
collTrav.showCollisions(render)

fromObject = player.attachNewNode(CollisionNode('colNode'))
fromObject.node().addSolid(CollisionRay(0, 0, 0, 0, 0, -1))
fromObject.node().setFromCollideMask(BitMask32.bit(1))

queue = CollisionHandlerQueue()
collTrav.addCollider(fromObject, queue)

fromObject.show()

collTrav.traverse(render)

for i in range(queue.getNumEntries()):
  entry = queue.getEntry(i)
  print (entry)

base.run()

colltest.egg (432.2 KB)

1 Like

So you and presumably others want the following full code and asset examples, modern with high poly counts:

  1. First person (I assume shooter focused) example the internal collision way and the Bullet way
  • What do we need to actually build to accomplish this?
  • Models: Environment, Character with Animations (the Armature way, the static way), door models and logic, NPC models and logic
  • General scripting solutions to solve running, jumping, stairs, aiming, movement AI (the PandaAI and the hard coded ways of course)
  • So we already have 6 different project goals here. That’s getting to be a lot of development. Is somebody paying for this?
  1. 3rd person (shooter?) example, with all those requirements as well

  2. We’ll just skip making examples for the scientists who use Panda3D. I mean where would you even begin? My Mars colony demo has most of the features mentioned above, but I wouldn’t say every line of my code are examples I’d want the whole world to use. I use Lerp Functions in weird ways sometimes.

It seems to me that a sample-game needn’t have all of the features of a full game.

For example, taking the hypothetical first-person shooter example, I don’t think that it need include jumping, stairs, or AI more complex than “move towards the player if beyond attack-range, and attack if within range”.

Indeed, I suspect that it would be preferable to keep such samples to a minimum: that way they’re likely to be easier for beginners to learn from.

I would imagine a first-person shooter example having the following:

  • One environment (With no doors; perhaps even no more than an arena)
  • One enemy
  • One player-weapon
  • One player-weapon impact-effect
  • AI for the enemy along the lines mentioned above: “charge at the player until within melee range, then do a simple melee attack”
  • A basic character-controller, handling floor-height and wall-collisions, but no more.
    • Along with a note that more-complex mechanics may call for more-complex implementations
  • A popup to show when the player dies
  • A score-counter
  • A main menu

Come to that, would the game from my “Beginner’s Tutorial”, but in first-person (and with new models as called for) be suitable?

I will say that I do like this idea, however. A selection of examples of how to perform single tasks (or very simple compound tasks).

The thing is, I suspect that, given only one sample-program showing a single way to do a given task, at least some users will assume that said way is “the” way to do that task.

So while we might not intentionally tell people that the samples indicate the only way to enact the things that they show, that impression may nevertheless be taken.

Great discussion here by the way, some ideas come to mind as I read through this.

What if we were to have very simple, independent/isolated samples that were very simple and concise (which seems to be what all folks here agree with). But, possibly in some cases where we would need to showcase something a ‘tad bit more complex’ like for example a 3rd/1st person sample game that those samples could import from the simpler ones.

For example:

  • samples/bullet_physics
  • samples/3rd_person_camera
  • samples/1st_person_camera
  • samples/AI
  • samples/network_comms
  • samples/networked_actors
  • samples/animated_actors
  • samples/3rd_person_game
    • main.py
      • from samples.3rd_person_camera import ThirdPersonCamera
      • from samples.networked_actors import NetworkManager
      • def main(): MyApp(camera=ThirdPersonCamera(), actors=[MyActor(pos=[x,y,z])], stateManager=NetworkManager(), physicsMgr=BulletMgr()).run();

Of course all that just random top-of-mind pseudocode. But in essence break things apart so they’re all really understandable small samples. Things that are by necessity more complex to explain would be samples that as an exception use code from other samples.

In the real-world as well, I don’t know that a fully-working 3rd person or 1st person type game would want to cram every detail into a single .py file, and showing how pieces can be split into separate modules also helps users of Panda understand how things can be modularized, re-usable, while still maintaining the simplicity of independent samples for the simple cases. And for the more complex cases - code there as well would be fairly small and concise - easy to understand as a lot of the minutia implementation detail would be abstracted out into other samples more relevant for that use case.

So for example when looking at ‘3rd person game’ example you wouldn’t be inundated with large amounts of super generic shader and lighting setup code, as that stuff should be part of another sample anyway, but the code you’d see really would be specific to building a ‘3rd person game’ if this abstraction is done properly.

Some creative sample code-organization might be needed to make this work. But Python really handles modularization well (OO, modules, etc.).

Of course there might be many other ways to handle this - like multi-step samples that add features over a progression of examples, etc. but I always looked at those as more of ‘tutorials’ rather than ‘code samples’. Minor nitpick - but tutorials are awesome in their own way as well, just that they take a bit more time to work through, and a sample should be something you just ‘grab and run’ and pull from that code what you need to make something work, breaking things apart like this might help to make things feel less ‘opinionated’ - as you can build off of the smaller pieces if you prefer, while also giving folks that want that ‘super opinionated sample that just works’ when desired as well. Seems we can have the best of both.

Thanks!!

-Sal

1 Like

I do like that idea! And indeed, I agree with your reasoning, I believe! :slight_smile:

I will add that it might be worth having each sample include a small program that uses it, so that there’s something that can be run to show just that sample in action.

So for example, the physics sample might have a small showcase-program that just spawns some spheres and boxes and allows the player to move them with some basic key-presses.

Finally–and this is a nitpick–I do question including networking or full Bullet physics in a third-person-game sample. Most single-player games don’t need networking, I daresay, and a basic third-person-game can surely be done with just the internal collision system, I feel, both making for a less-complicated sample program.

Wonderful initiative :+1: !

Fully agreed! In fact, there’s another thing that nobody talks about anymore and which could be built around these samples (both basic and more advanced): how about creating a tech-demo for Panda3D? It could consist of multiple segments, with each of those segments showcasing a different type of gameplay, using one or more of the samples as its base.

It’s something I’ve been wondering about for a while now, but never dared to suggest since I’m fully aware that this would be a very time-consuming undertaking. But now that I see that “stuff is about to get real”, it seems like a good time to talk about it.

Here are some general content-related ideas that I’ve been considering for a sci-fi-oriented demo:

  • An intro, inside a hangar, where you see a starship being built – or repaired – by a bunch of drones that are floating around. This could make use of a sample that demonstrates procedural generation of geometry. As it happens, I have proposed such samples here.
    This could be made to look really impressive, with lots of cool shader effects, showing off the capabilities of the engine.

  • The first playable section of the demo, kind of like “Act 1”, where the completed starship flies out of the hangar and engages in space battles with enemy fighter ships. So this would be a flightsim-type segment with some form of aerial combat.

  • Act 2: the starship docks at a partially destroyed, rotating space station and you, the pilot, walk through the corridors, looking around for clues about what happened there. This would be an adventure-type segment.

  • Act 3: the player encounters hostile… (let your imagination run wild). This would be a shooter-type segment.

  • Act 4 (end): the player discovers an alternate way to leave the space station, by moving through portals. This would be a puzzle-type segment.

As for the player’s weapon, every memorable shooter game needs an equally-memorable gun, I suppose. After the Gravity Gun and the Portal Gun, enter… the Matrix Gun! It can absorb kinetic energy of 3 different types, corresponding to the 3 kinds of transformation (translation, rotation and scale). It can then “shoot” this energy at objects (for solving puzzles) or at enemies (to throw them against walls, spin them silly, or shrink them so you can squash them). As a puzzle-solving example, suppose you’re stuck in a basement with a broken escalator. You see a ventilator whirring above you in the ceiling, you absorb its “rotational energy” and shoot it into the escalator to make it work again.

If you were looking for some whacky ideas, I guess you’re sorted :grin: .

Anybody else who thinks a tech-demo would be a good idea? Or is it just too much?

Hmm… It’s ambitious!

The sci-fi setting might allow for increased re-use of textures, and thus reduced work: lots of “plated metal”, or “futuristic moulded plastic”, or whatever aesthetic is decided upon.

Conversely, that might look unimpressive, so it might be worth then adding various “fancy” visual features: holographic screens, glowing lights, etc.

The “Matrix Gun” does sound both neat and unusual. I do worry that it might make for quite a difficult thing to balance and build around in what is likely to be a project with limited development, but it’s likely not impossible.

I might suggest that, given the scale, the project be split amongst multiple devs. Perhaps one person for each section–so one person does the intro, another does the space-battle, and so on. Presuming that enough devs are found, that might make for lighter work.

[edit]
A few thoughts, aimed towards simplification:

  • What does the Act 3 “encounter with hostiles” add that the earlier space-battle segment doesn’t, at least in terms of being a showcase? Could the former perhaps be removed in favour of the latter?
  • What does the Act 4 puzzle-solving segment add that the Act 2 adventure segment doesn’t? Again, could the former perhaps be removed in favour of the latter?
  • In the space battle segment, what about swapping the full six-degrees-of-freedom mechanic (if I’m understanding correctly) for a Panzer-Dragoon-like “auto-scrolling 3D environment with 2D movement” mechanic, alongside SHMUP-style enemy waves?
    • It could still look neat and spacey, but both player-movement and, potentially, enemy behaviour might be simplified.

On a somewhat-contrary note, let me put forward the alternative aesthetic suggestion of sci-fantasy: imagine, for example that space-battle involving flying out not in a star-fighter, but a cyber-dragon! Plus it might allow for some neat–if likely ambitious–art!

A tech-demo should be able to convince potential developers that Panda3D is powerful, so if one is ever made it needs to be truly impressive, I feel!

That’s pretty much what I had in mind, indeed :slight_smile: .

This should definitely be a community project; not just one person but preferably one group of people per section. There are those who excel at making models, others who are better at texturing or animation, still others prefer to focus on coding, and so on.
If several people combine their skills, with good leadership this could become something great, I think. Otherwise I fear it won’t get very far.
Let’s be realistic: it will take a lot of time and effort to make this happen. It could easily take months (and that may still be optimistic) before it gets realized, but this seems like a good time to start thinking about it, as one can already take the development of such a project into consideration when building the new samples. That’s the reason I mentioned it.

Well my idea was precisely to showcase multiple different game types, while you seem to suggest incorporating as few as possible? Granted, that would make things a lot simpler, but to me it’s not a matter of making it easier to develop, but to make it a more complete, varied experience for the gamer. Even though it will take longer to develop, it would be worth it, I think.

To answer in more detail:

What I imagined for the space-battle was more of a flightsim-type gameplay with dogfights from a cockpit viewpoint, while Act 3 would be more like a regular 1st or 3rd person shooter.

Act 2 would be intended to be a more relaxed experience, to take a breather after the hectic space-battle. You could just look around, get your bearings and find things (like the Matrix Gun) that would help in later stages.
In Act 4 however, you would feel the pressure of having to leave the space station as soon as possible, because: “Self-destruct sequence initiated” :stuck_out_tongue: . What I was thinking of using for this act was something like the portals in the old “Prey” (2006) or “Portal” games, but with the portals being less obvious. For example, you could be locked into a room with a killer robot just outside, busy melting the lock on the door. There would be no apparent means to escape; all you see is a seemingly ordinary painting on the wall… which you should find that you can actually jump through and end up in a weird-looking, alternative universe, but still aboard the space station. (The fact you’re in a painting could be an opportunity to apply some cool visual effects.) You would move through different portals – taking you to unexpected places – before you finally arrive at the exit of the space station.
So apart from play styles, it’s also a matter of mixing up the pacing a bit, which could contribute to a more enjoyable player experience.

Sure, my intent was merely to provide some ideas, none of it is written in stone :slight_smile: .

Sounds very cool :slight_smile: ! Again, my ideas were just meant for inspiration; if the tech-demo ends up looking completely different than what I had in mind then that’s just fine, as long as it becomes something exciting and impressive!

That’s fair, on all counts!

I do wonder whether a tech-demo needs to incorporate as many types of gameplay as possible, however. And indeed, if so, there are many types of gameplay not yet covered: strategy, racing, hack-and-slash, RPG, stealth, visual-novel, and more besides!

Rather, I wonder whether it might not be better to just give a few varied types of gameplay, in order to show Panda’s power and flexibility. Too much may overwhelm; and conversely, a tech-demo seems to me to benefit from being short and to the point, from conveying its message with impactful brevity.