[SOLVED] Interaction between Player and Scene: How to set it up during modelling operation?

Dear all,

I am learning JME and I have a question regarding the interaction between the player and the world.

Imagine a house where the player can interact with multiples elements: Door can be open/close, tap can be open and water will fall, pen on a desk can be picked and put in an inventory, and so on.
What do I need to ask to the graphist when he/she will create the model of the house? Does he/she need to create all “static” component in a scene and all “dynamic” objects (door, tap, pen…) will be added from source code when the scene will be loaded? Or can he/she already integrate the objects in the scene and there is a way to select if using JME? If the good answer is the second option, how can I understand that the Player is in front of a dynamic element? I can use a Ray to check the collision but how do I know that the Player is looking at a dynamic door and not at a static wall if both are integrated in the scene during the modelling?

Extra question: is it correct to say that when a Player open a door (e.g., when he/she uses action key), it launches the animation of the door which is integrated to the scene during the modelling?

I hope my questions were clear. If not, do not hesitate to ask for more details.

Many thanks for your answers.

Hello, Depends how you want to project you game, is it gonna be small, medium or bigger production? how much time you got? do you want make it quick or “with a good code core”?

If you want make small game quick:

  • just model all scene/scenes as single model, lets say in Blender, just make sure windows/doors are separate “objects” so you will be able animate them. Same about equipment(since i understand you dont want physics here). You need read SceneGraph to understand your Extra question answer. (each “object” can have own animations, also you can have coded animations like rotations/etc)
  • Use simple Raycasting like you said, and animate “Geoms/Nodes” that have related name like “Door2” or pickup items with names “weapon1” and remove geom and add to some game logic list that player have item
  • Player walk, can be done with physics, or just coded, depends on area model.
  • use low tris/quality assets to make game simple
  • do not make a lot of content
  • for model game import/export use simple .obj if you will code all simple animations

if you want small/medium but with good “core code” game:

  • use ECS(Entity Component System) liek ZayES or other library.
  • Determine All Doors / Windows / Items / House / Player / Etc as Entities declated in ECS
  • in ECS add actions for each element that need them and assign ECS system code to be able to execute this actions.
  • Add some physics component and system for items / player / etc
  • for action also can use raycast here, just now you no need check Spatial name, but you can check Entity itself (taken from some ID hold on spatial)
  • optionally use PBR and good quality assets(models/etc) with animations/etc
  • add more content
  • Minie library for physics suggested / use full physics for player and area
  • for model game import/export use GLTF/FBX with preferred PBR shader usage and full animation support

if you want bigger game with good “core code”

  • same as with small/medium with good “core code”, but with even better solutions.
  • optionally custom editor added
  • optionally use best assets as possible with Animations / IK / physics / morph shapes / etc
  • add a lot of content
  • just make it better, for example use Inverse Kinematics so player “hand” hold door handle or push door, or use animation for it, just positioning player, etc etc etc etc
1 Like

There’s more than one way to do it. My preference is to create the “dynamic” objects as separate models and add them to the scene at runtime. This is a very flexible approach and also in keeping with JME’s code-oriented philosophy.

@oxplay2 Many thanks for this very complete answer. Indeed, I will start with small game but I like to have a good code core to get good practice as from the beginning.
I will check how to use ECS. I never heard about it before.
And I will keep in mind to use GLTF/FBX with PBR shader.
Thanks again.

@sgold Thanks for your answer. With this approach, I am afraid to always have to recalculate the positon of the door, etc. I have really bad knowledge with 3D tool design. So it will add a complexity in the discussion with the graphist to understand where I need to place the objetcs. I will then try the ECS approach.

1 Like