in case you haven’t noticed:
In the editor everything works, all collisions, no issues
Once I build and run it, no collisions any longer
And build settings have not changed
Unity 2022.2.1f1 (Core 3D)
and doesn’t work in 2022.2.2f1 either
“Successful build” though… lol
What I have tried:
applying a rigid body to the structure
re-importing the mesh with some modifications
It seems to only apply to the Level mesh / structure object
Are you moving physics yourself? If so keep this in mind:
With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.
Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.
PS - your game reminds me a little bit of Descent… I love it with the little lights on the guys going into the tunnels!!
Oh thanks, yeah Descent was one of my favorites… I think even my first 3D game on a PC, many eons ago.
with regards to the Physic engine API, perfectly understandable. I wasn’t entirely aware of everything but have listened in on that a little bit previously. Thank you for pointing this out in detail.
The things that makes no sense is that the Level Structure doesn’t use a rigidbody and the player uses a character controller and the move functions, as recommended.
This part never changed and always ran fine, never had any trouble.
Maybe this is the issue, that the level doesn’t use a rigidbody?
But I have tried that already.
Edit: I think I got it now. I am indeed conflicting things, I didn’t even notice. I will report back in case it still persists after putting some order into this, lol
I think the CC is really only usable as a standing person, not so much a flier… I don’t think the CC can rotate, eg, if you roll it 45 degrees to the right I think it just doesn’t rotate, does not lean over.
Yeah, I think that for what you want it would need to be all Rigidbody physics. That’s how I did the one 3D full flight mode I have in my Jetpack Kurt SpaceFlight game:
Now you have me thinking about putting Jetpack Kurt into some tight twisty tunnels like your levels! It’s so compelling to master flying around stuff like that!
Impressive!
That is where I would like to be at, at the moment… but meh.
Bad news, the issue still persists and I have rewritten a few sections to completely rule out wrong mishandle of components.
So here is what I did:
Every object using Rigidbody, handles it using the rigidbody methods, no exceptions. This section is completely cleaned up and smooth. At least inside the editor.
I have reimported models and found a few scaling issues (not exactly issues, more a higher scale than expected. Tweaked the values in the code to match speed and force units), but they have been fixed and didn’t change anything
Here is a couple things that I am suspicious of:
Build Cache issues
Mesh Collider issues (I use a level structure that does NOT have a rigidbody, but that shouldn’t matter as it has a collider, as stated, and runs perfectly inside the editor)
Scaling issues… maybe the mesh collider is near the world origin and not scaled to the actual size at runtime… but it worked all the time previously.
Ghost resource that didn’t make it off the system
Resource tree update issue
Call hierarchy issues related to components
or I am the first one to have created a Mesh Virus
I am absolutely out of ideas at this point and relable this topic as “Bug”
UPDATE, It must be a bug
Here is a new issue popping up:
My Level Structure / Mesh has been duplicated out of the FBX file as single (Mesh only), I applied Mesh Collider and the Material + the physics material, deleted the old level object (fbx extruded prefab), now when running it in the editor, it completely ignores the Physics Material, everything gets stuck when approaching the collider, and when building it, everything works. Now it’s backwards. And this tells me that Unity has a problem with it’s “Mesh Collider”-Component
Hm… whoa, I just realized and had one more thought: is this a giant collider facing INWARDS?
If so… Three things to check:
make sure mesh winding normals are facing INWARDS … they may differ wildly from lighting normals which affect visibility / lighting. The winding is necessary for physics, AFAIK.
it might be that you must make two halves of the colliders for given enclosure… I’m not 100% sure how the bounds checking might work being inside a single inward-facing collider
Make sure the collider is NOT marked convex!!!
EDIT: now I am gonna go make a quick test with my game and a single inward-facing mesh collider just to see what happens…
I should probably post a screenshot of the collider mesh
It’s clean, normals face inwards, not convex
Let me know what you observe. As I have mentioned, this was never an issue and just started out of the blue (well, after my AI script started implementing Raycast methods)
I made an inward-facing mesh and flew into it a bunch (ow) both in my Unity Editor and also as builds for the Mac… I was flying Pilot Kurt, not Jetpack Kurt, but a similar compound collider going outwards… the inward facing mesh impenetrable. BOOM
And I also tried ticking the inward-facing mesh collider as CONVEX and it just instantly ejected me from the volume, but did so before I had any forward velocity so I took zero damage. I tried flying back into the enclosed room but I slammed right into the collider again and again.
That was fun… I’m slightly dizzy actually because my cube interior was so bland…
I gotta take some pointers from your lighting tricks here :), if I wanna do something with this…
yeah, that is how it always behaved.
In my first video it shows that you can fly in and out, and nothing happens (in the build). And inside the editor, no problem at all, it detects the inwards facing normals. It’s a back-to-back demonstration.
I don’t know, the issue is now that it detects the collision when using the raw mesh object but seems to ignore the physics material inside the editor.
…maybe I am losing it, lol
btw, thanks for sharing the Jetpack project. There are some cool controls in there that I would like to check out
No, no, something’s going on… there’s one more thing this reminds me of. When you spawn, are you perhaps initially spawning this thing outside the interior, eg, allowing the Rigidbody to instantiate, and then subsequently moving it inside when you decide where to spawn? EG, are you NOT using the Instantiate() with the position argument? Even if it’s all in one frame?
Luckily this is all following the GameObject domain local vector.
Can be confusing but I got that part down solid.
The objects for now aren’t instantiating from another script or method, at least not from my end.
They are simply pre-placed (inside the level mesh).