I have a strange problem with a First Person Controller (FPC), because when I add any collider component, First Person Shooter (FPS) is being dragged by something. I have no control over it (the arrows keys seem not working). It’s weird because if there are no collider, everything works great… It seems as if some force drags the FPS.
I know this sounds harsh, but could you just read your post again and think about what kind of information you are giving to others. FPC and FPS are clearly not useful, because it is not clear which ones you are referring to. Are those custom ones? Did you get them somewhere, maybe modified them? How is the movement implemented? Physics based, kinematic, …?
Did you try it in an empty scene where you just have a plane and place the FPS? Does it work?
I edited the post. Now there shouldn’t be any problems with FPC and FPS. Sorry for that, guys. Customs ones? Yes, have customs ones, but I tried the standard ones and the same. Everything is good, but when I add a collider (every collider) my FPC starts to move in one direction as though a force pushes it. I don’t use any force.
I made an empty scene - the same problem.
If you are using a custom one, how do you perform the movement? Are you using a rigidbody? Is it kinematic?
Are you getting any error messages or warnings?
no messages and warnings
i have rigidbody to Graphics attached (Use Gravity, Continuous Dynamic, Mass: 1, Drag: 0, Angular Drag: 0.05, no kinematic)
Uncheck Box Collider - everything OK
Check Box Collider - problems
How do you perform the movement?
Why is drag 0?
The movement?
I use the arrow keys and WSAD - all standard.
I have always used Drag 0 for my FPCs. Something strange in that?
Do you use
or
or
…
If you have a physics based character controller, drag should definitely not be 0, because it is natural that a physical body slows down over time e.g. due to air resistance. If you are using a physics based character it is also important to have properly setup physics materials.
I don’t use the code you wrote.
It’s a simple FPC so I don’t need any additional effects like drag. I use default settings. I recorded a movie - maybe it will be easier. There are errors or warnings but they aren’t connected to my FPC.
I assume you are using the First Person Controller that comes with Unity in that case. If that is true, don’t attach a rigidbody to the graphics. The character controller component itself has some kind of rigidbody internally. If you want to have physical interaction, the character controller is usually not the best solution.
OK, but removing Rigidbody don’t change anything. It’s connected to Colliders and I don’t know why. I have tested all possibilities and I have no ideas.
I will post the movie later because I am downloading new OpenSuse 13.2 to test it with Unity. My Internet connection isn’t too fast.
I just created a new project, imported the standard character controllers, placed a plane in the scene, dragged the first person control on top of it, added a box collider to it, changed the y size to 2 and everything works as expected. Did I forget something?
It seems there are several other scripts that you attached additionally. Maybe one of them is causing the issue. However, I wasn’t able to reproduce your issue.
Yes, its weird. I created a fresh scene, added a fresh standard First Person Controller and when in Play Mode, all works great (no my scripts or other components added). But when I added a Box Collider (Only a Box Collider to the standard components, nothing more!), FPC went mad.
The character controller already is a collider, it is my understanding you should not have either any more colliders attatched to it or any rigidbodies for it to work properly.
But sometimes the in built collider doesn’t work as should.
A fresh scene and the standard first person controller:
Like I said, you can’t add more colliders under the character controller.
If you need compound collider functionality you can’t use character controller, you will need your own rigidbody based controller.
Why are you trying to do this anyway?
Ok, ThermalFusion. I’ll try without the box collider. However, you should know that I haven’t had any problems before. And why this charcter controler drag exists I don’t know. What force are there?
I use the Collider in the character controller for the OnTiggerEnter function. The Player opens the gate. Can I use the default collider for that?
I checked all in detail.
I created a fresh scene, standard assets imported: character and terrain assets.
I created a terrain, added a texture for the terrain and added a standard character controller. No Rigidbody.
1/ a Cube Collider attached - the character goes crazy
2/ a Sphere Collider attached - the character goes crazy
3/ a Capsule Collider attached - the character goes crazy
4/ a Wheel Collider attached - the character WORKS NORMALLY!!!
5/ a Terrain Collider attached - the character WORKS NORMALLY!!!
6/ a Mesh Collider attached - the character doesn’t move
Yeah, you CANNOT attach a collider to a character. Actually, this has always been a problem for me, even before Unity 5 (well, I say it’s a problem, it isn’t really. it’s not that hard to work around)
The force you’re seeing is that the character controller is colliding with the collider you’ve attached. Therefore, it tries to resolve the collision by pushing the character controller out of the collider, but since the collider is attached it keeps pushing forever.