I am able to use that^ code and hop happily around on the cube to my heart’s content but I just cant get my created terrain to work. When I load up I drop through it into the abyss of jMonkey space. can someone try to point me in the right direction please? I’ve been reading and trying all the stuff that I can find-sorry if I missed something obvious.
My current code:
// init a physical test scene
Spatial terrain = assetManager.loadModel("Scenes/1234.j3o");
//Plane plane = new Plane();
//plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y);
//terrain.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0));
//source code just uses space not sure if getPhysicsSpace is what I want
I am pretty sure your code looks correct. Does the issue happen with all of your terrains, or just this one?
I have experienced the same issue with specific terrains, especially on older maps where I’ve saved/loaded its terrains a lot. (I only just re-introduced physics into my game with Minie, so I am still occasionally discovering certain terrains on my old maps that have this issue)
I’m fairly certain this is some sort of bug with terrains that I’ve been meaning to make a post/issue about actually, so I’m curious to know if the physics works with the same code when you try with a fresh new terrain.
If so, then a temporary workaround I plan to do is to just re-make my broken terrains with the broken terrain’s height map data and material; but discovering the underlying cause if this is a bug would also be good.
I did a little detective work and it happens with all the terrains that I make, which is just in the basic simple way here:
Right click Scenes (Empty jme3 scene)
Name it something desperate (click Finish)
Right click (edit Terrain)
select scene root and click (add terrain)
select terrain size (total/patch)
alpha blend texture size (Finish)
I’ve tried messing around with various things like adjust the total size, trying out a hill, making the character model larger etc. Yeah I’m not sure if I’m just not doing something properly somewhere or if it is indeed a bug in which case at least I can replicate it 100% of the time
I’d also suggest doing something like respawning the player if they’ve fallen through the world, since falling through the world is something that can still occur for other reasons, like if there’s a big lag spike when you spawn npcs right after the map loads. I tried doing extra things to make it not happen (and could still do more), but I still always find edge cases where an important NPC is missing because they somehow fell through.
I like to check for all my Players’ and NPCs’ Y value and then I force respawn them if it gets to a really low altitude. I’ve watched a lot of youtubers and streamers who play new releases and Indie Games on steam, and I notice they always like to try to find ways to break the game, and infinitely falling through the world is always the most common trick they manage to find right away, whether its from walking off the edge or finding a spot to clip through. And I’m always surprised by how many games released on steam don’t use this simple trick (or anything similar) to just reset the player / npc when they fall to an unrealistically low y value, since things like that can be the determining factor between whether the player keeps playing or alt-f4s and calls it a bugged game.
Having a fly mode also helps a lot for debugging these issues, so when you fall through, you can fly up and down and around to see if you can trigger the physics interaction in another point.
I lucked out, because I “accidentally” gave myself a tool for this when I made a fly mode, so the idea wasn’t even intentional on my part.
If the player holds the fly-down button while on top of the terrain, they coincidentally move fast enough to get pushed through the terrain (thanks to my light weight, janky physics system I made for simulating player movement with simple Rays) This also means I can’t let players use fly mode or they can fly through anything they want, but I wasn’t planning on that anyways thankfully lol.
Yeah, in my case, I still have a “super run” enabled that moves faster than the physics engine can handle but is fine if you are flying over large distances. But the more controlled way is to just place blocks on yourself.
Still, now that I have scriptable tools then I can give myself a developer tool and close off these ‘features’.
I dont know if it is solved, but try moving/warping the chatartercontrol/object to say, like 100f/200f or something like that. thenn see if you fll on the terrain(I once had a similar issue, because my character started below the terrain)
I was able to fix this I forget my exact error but I think my capsule collision shape was too large for my model and it was actually loading so that the bottom of it was below the terrain. Not sure if that was exactly it but something like that, so I guess I was below the terrain as well haha.