- Home /
Strange collision bug?
Guys, i am experiencing a VERY strange bug/problem on my game. I am working on an FPS, and it took me quite some time to make a "playable" underwater mode for the standard first person character, because it uses a character controller, two scripts interacting with each other at the same time having everything on private, a kinematic rigidbody, etc... But after some hours i was able to make a underwater mode for it that disables the character controller, unchecks it's rigidbody's options and restricts it in some positions and rotations, and then add a script that will make the player move in the direction of the mouse. But, i am having a problem with adding this to two prefabs.
I have two EXACTLY EQUAL prefabs, but with different names. Now the strange thing is, with prefab n1°, i can't pass through walls when on underwater mode. BUT prefab n2° can! Wtf? How can this be even possible if both are the same thing?
#EDIT
Both prefabs have the exactly same components, same scripts, and same values. The script uses private variables to hold all the references, and changes the prefab's behavior while underwater based on that. So? This means that IF there was an error, or different behavior on each prefab by the script, i would know.
Obviously they're not, you just missed something. Layers? $$anonymous$$ovement in the wrong update?
No, you didn't get it. They are literally the same thing. Same scrips, same components, same numbers, same everything. I checked everything hundreds of times, and there is absolutely NOTHING different, but one works and the other doesn't.
It's not something about movement, it's literally the fact that one prefab collides with things, and the other just doesn't for some reason, but they are the SA$$anonymous$$E.
Answer by csalzman · Apr 14, 2017 at 01:39 AM
Are you sure that nothing in your scripts is referencing the name of the gameobject?
Try creating 4 objects, 2 from each prefab. Do they exhibit the same behaviors? Do the two that are based on the prefab that goes through walls both go through walls? What about the other ones?
Check that they are both using the same tags and layers.
Edit->Project Settings->Physics and check the collision table and make sure everything is working as planned.
And, when you figure out what's going on, please share an update! This one has me intrigued.
Something between the two is different and you'll find it eventually. Yes, I know you checked many many many times. I have been here before too tearing my hair out just to find that, oh yeah, that one little setting is off.
1°- The clones of prefab n°1 don't pass through walls, and the clones from prefab n°2 do.
2° - Same Tags and Layers.
3° - Everything on Physics is okay.
Important Note: The part on my script that SUPPOSEDLY would disable the things from the prefab, and enable some others while still making it collide doesn't work with tags, it gets the components from the GameObject it is attached to, and both prefabs have the same components and values, that's what's making me crazy! And you know what's absolutely insane? I placed both at the same time, jumped on a pool with both, and one passed through the floor, while the other don't, and everything while i was checking all the components, and everything was the SA$$anonymous$$E!
Here are two pics: One making a comparison between both prefabs, and another of the script part.
Throw a line in that if
statement like the following:
Debug.Log("This worked")
I'm really curious to hear if it's actually firing on both of them. If so it should show up a few times in your console.
If it isn't that means that underWater and doOnce aren't getting set appropriately elsewhere in the script.
How does underWater
get set?
I made it public for now for testing. For now it gets enabled when the player hits the Water. It detects if the object that hit it has the player tag, and then based on that activates the bool. The doOnce does exactly what it is supposed to. It makes sure these conditions are only met when the player enters the water. These are working properly, otherwise the player would see the water normally, ins$$anonymous$$d of the water effects.
Using Debug.Log
worked as expected. Both prefabs show the log once they hit the water. I tried using it AFTER all the changes are set, and again, it works on both.
Again, same components, same values, same everything, including when underwater. I decided that i will delete the bugged prefab and make other prefabs based on the one that is working, and i will also report this as a bug. Question closed i guess =(
Your answer
Follow this Question
Related Questions
Collision Problem - Terrain collider remains flat after raising or lowering it 0 Answers
Stop Slow on Collision with FPC 0 Answers
jump on collision - first person controller 0 Answers
How to make the first person controller to swim like a fish? 1 Answer
First Character and loose hit points 1 Answer