- Home /
The question is answered, right answer was accepted
Is it possible to import Blender .fbx scenes that cause Unity Collider Bugs?
So right now I'm programming a game where all the player movements are determined by casting various rays. Rays from the camera to the position the player tapped on screen (Android) or clicked on screen (PC) determine where the player will move. And rays coming out the bottom of the player determine the height of the player so he can change elevations when walking on top of or falling off objects.
If the player is standing at position X and the user taps position Y the player will automatically run towards position Y until they are within a certain designated distance at which time they will stop the run animation and play the idle animation.
Because of the way my game is programmed it is very easy for me to determine when colliders in the scene are not working as expected.
For example if the ray does not hit the collider you won't move to that spot, or you will be unable to interact/attack/pick it up.
I am no longer doing any of the 3D art for this project (we use Blender .fbx). I have another artist doing all the art and in our 2 latest scenes we are having some extremely strange issues going on that I don't understand.
This is the first serious project either of us has worked on so we are still learning all the time. But I do fully understand how my players movement scripts work and the behavior I am seeing makes no sense at all.
For example we have a scene where you use a lift to go to a ground plane on a higher elevation. My first concern is using planes themselves to detect my ray cast. I don't know why the artist decided to do this but my immediate concern is that the planes themselves are the cause for the players downwards ray cast not setting their feet to the correct height.
So my artist is bending areas of a Plane for things such as ponds. So my first question is can Planes even work any kind of collision detection that requires 3D Depth? Even if the plane is shaped to be not flat it appears to me that they will only provide flat collision detection in my ray casts.
But that is the least of my concerns although I'd still like some info on that :)
So I noticed that there was only 1 Plane in our scene this seemed strange because it appears that there should be 2. One plane for each of the top and bottom elevations the player can travel between using the lift. However selecting the single Plane in Unity Editor allowed me to move them both simultaneously up and down as if they were 1 object despite being at least 30 meters apart vertically and not connecting at all visually...
There was also only 1 box collider for the Plane which seems impossible given that the dimensions of the collider was flat, and that the player was able to walk at the correct height which is determined by this one collider at two separate elevations.
So this all seemed very strange to me but I wouldn't mind if it worked. The immediate problem was that the player could not lose elevation even if the plane looked like it was slanted. I told my artist we need to try to use a cube instead of a plane so we can use mesh colliders more accurately for depth collision calculations.
So in no time my artist provided me a new .fbx model made in Blender which was identical to the higher elevation Plane except it was a cube not a Plane.
And this is where things just got weird...
Deleting the top plane and replacing it in the perfect position with the 3D cube ground did not solve the problem, the player could still not lose elevation for the pond even when removing the water. I have already done this same exact thing in other scenes with the player going up and down in elevation based on the raycast being shot from bottom of player to determine their foot position. I know it is not a problem with my scripts.
So then I started getting desperate and deleted both the old plane and the new cube for the upper elevation from the scene completely. What was left according to the Unity editor was nothing. You can visually click in this area where the ground used to be in editor mode and it will not select anything in the Heirarchy. I also carefully went through every single object in the entire scene including child components and there is nothing there. No collider is present according to Unity...
Yet the player is still able to run on the ground here perfectly as if the collider was exactly where it had been originally. I know this is true because the player cannot ever be in the idle animation state unless the destinationVectorPosition variable is a very small distance from the RayCastHit collider point (from the ground collider). In any other area of the game if you were to delete the ground or disable the ground collider the player would start the running animation infinitely because the collision detection from the cameras ray cast point would never be able to hit a collider close enough to satisfy the necessary distance conditions in relation to the destinationVectorPosition to start the player Idle animation.
Hopefully you're still following me I'm trying to explain in full detail because it's such an unusual problem and I can't find anything related in my searches so far.
I fear we have discovered some kind of Unity bug where certain .fbx models from Blender can be created in a way that upon import to a scene Unity does not accurately detect or even visibly show the collider. The whole problem seems to be caused by how that Plane was showing up as one object in Unity Hierarchy but really it seemed like it would have had to been two to work correctly or make any sense whatsoever. I have tried deleting literally everything possible from the scene and the player can still run perfectly at this spot. The collider is most definitely still there, I just can't select it or find it anywhere in Unity :(
My artist may have mentioned something that could have explained it. I don't remember the exact words but it was something along the lines of "I might of split that ground Plane into two pieces from one and forgot to .... (can't remember what they said)".
I was hoping it would just be that one spot, we could just forget about using a pond there... but now our newest scene has the exact same problem on the lift .fbx file. The players feet cannot rest at the correct height of the lift floor, it's as if another invisible collider is interuppting the raycast but it cannot be found anywhere in the scene once again...
This rays max distance (shooting from bottom of player) determines where the players foot should rest, if the ray hits no collider the player falls, if the ray hits a collider before the max distance the players foot will stand exactly on top of that collider. It works in 9 other scenes perfectly but now all the sudden we are getting invisible colliders!? What the heck is going on here? Please help me!
Unfortunately I am not the one who created the .fbx so I have no idea what they did, and they don't seem to understand my issue. I just spent about an hour creating a detailed diagram for my artist so hopefully tomorrow they will understand how to fix this. But I am looking to find all the information possible to help them fix it.
TLDR Version:
1) Is it possible to import Blender .fbx files in a way that Unity does not recognize or display them correctly? Therefor you can break Unitys ability to select and use these objects in the scene resulting in fully functional colliders that cannot be found or deleted no matter what you try?
2) If there was an object like this that you can't select by clicking it's visual location in the Scene View or checking the entire scene Hierarchy is there any way to locate it manually through either script code or some other Unity Feature I am unaware of?
3) Am I correct in thinking that planes would never be a suitable way to detect depth collision for the player to move up and down even if the artist was to shape them that way visually?
4) For anyone experienced with 3D modeling of .fbx files using blender, do you have any idea what could possibly cause this to occur in Unity? I am trying to help explain to my artist how we can fix this or avoid the problem altogether.
5) Is it possible that this is a brand new bug caused by Unity 4.2 if nobody knows what I'm talking about? We just ran into this after switching to 4.2 but it's impossible to know if it's a Unity bug or if my artist somehow did something with Blender .fbx that has always had the potential to break Unity's functionality.
I will provide more information if necessary after talking to my artist tomorrow if we still can't figure out how to fix it or what's causing this.
Some additional info if it helps anyone answer:
The artist is still using Blender 2.6 which according to the latest Blender version 280 bugs have been fixed.
I'm starting to suspect a Blender bug I'm seeing all kinds of version 2.6 is buggy stuff in my searches.
Here is the info today my artist sent me that might explain the problem better:
"And as for the planes in level 2, they were 2 planes then I combined them because I thought that would be easier to work with but then later made them 2 separate planes again because I realized it was better to keep them as 2. But you must have gotten the scene before I separated them if they were as 1 object in your unity. If so then that would be like the worst thing I ever forgot to tell you! And before I separated them I used an empty game object to make the collider for the upper level. So like I said, if you could actually see the collider in the scene that you couldn't figure out what it was attached to then it was the one I gave to the game object. are the 2 grounds still 1 object in your scene? "
Also found this related to Blender 2.6 improvement plans for their future development:
-Fix our duplicator system, animation proxy (for local parts of linked/referenced data)
I'm not sure if I understand what that means but maybe duplicating objects in Blender ins$$anonymous$$d of creating new ones can possibly cause problems for the referenced data so I can't find it in Unity?
I'll update this some more if we can't solve it soon, this is a super annoying problem for me.
Answer by RyanZimmerman87 · Aug 05, 2013 at 01:58 AM
So it is now working!
I should be super happy and relieved right now, which I am kinda. But I'm more just confused...
I spent so many hours troubleshooting this trying tons of potential solutions, to have it all the sudden start working and not even know why is a bit disturbing.
But my best guess is that somehow our project got corrupted either the scenes themselves or some file structure/data. By updating the project with new scenes/packages it somehow refreshed or updated the file structure/data and solved the problem.
I don't know enough about how Unity works to know if that's even possible but it's my best guess at this point. Either that or it was just some random bug that I fixed without even realizing how...
But I guess it's a good thing despite my mass confusion at the moment :)
Edit: Also worth nothing that planes do in fact work for the accurate collision detection on the ground.