Please Help Me! Camera going crazy upon setting collision box collider on player
I am creating a game for my school project (Which is a shooting maze game) and i am now creating a box collider on the player so it cannot pass through walls. However, despite of all the colliders installed, it still passes through walls and the character starts flying! (In fact before this both my players and the walls had colliders but it still passes through walls. Also i now have a problem that the collider is preventing it from passing through items (Which are not programmed yet.) please help?
P.S. I found out this happens when my player collides with a wall, or anything with a collider.
P.S.2 Tried the sphere collider and now the camera still goes crazy, but it tilts all the way to the bottom of the game and inverts.
This picture is my game. The ball with a gun is the player. (Outdated)
Example of camera going crazy.
Current situation. Now the camera sinks into the floor after a sphere collider.
Are you using physics to move the player, or some other method? Are you doing it in fixed update? Have you looked at any collider/physics tutorials?
the box collider is straight from the physics component toolbar. The only script i had is a movement script straight from the unity 3d tutorial for a shooter which worked perfectly in this case (Save for passing trough walls and the character not changing directions upon travelling.
Firstly, for moving characters, it is often best to use the ball of capsule collider as corners of the box collider can sometimes collide and force your character to fly around. As for passing through walls, can you go completely through them, and walk into the next room, or do you just see through them. If it's the first, do you defeinitely have a rigidbody on your character; if it's the second, is you camera inside the characters collider, or outside.
If you have IsTrigger on the colliders set to true, no physical collisions will occur, is trigger is used for things like item pickups, where you want to note that you have moved into the item, but you don't want your movement effected.
you can try adding a script to your player with two methods:
OnCollisionEnter(Collision collision){
Debug.Log("we collided!");
}
OnTriggerEnter(Collision collision){
Debug.Log("we hit a trigger, but our physics wasn't effected!");
}
Then you will see what happens in each scenario
But i get an error saying "$$anonymous$$ethod must have an return type".
Just needed to have void in front, apologies:
void OnCollisionEnter(Collision collision){
Debug.Log("we collided!");
}
void OnTriggerEnter(Collision collision){
Debug.Log("we hit a trigger, but our physics wasn't effected!");
}
This is not the entire code that you save, you need it inside a class and you need to import the unityengine library and so on. If you do not know how to utilise code snippets then please do some tutorials as I there is no point me $$anonymous$$ching you trivialities that are everywhere on the internet.
ok i see. sorry about that. Back to the main topic, i had added a sphere collider and now the thing still goes crazy but in a different way. this time, the camera (Player?) slowly pans and sinks to the bottom until the screen is inverted. I will add a picture of it here soon.
In rigidbody, set all the rotations to frozen except Y rotation.
Your answer
![](https://koobas.hobune.stream/wayback/20220612075013im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Best way to animate a shooting-arm on my ball (Player)? 0 Answers
Shooting Gun Script 4 Answers
Reload only when not firing 1 Answer
Third person controller moving backwards when shooting 0 Answers
How to fire bullets from multiple guns at the same time? 2 Answers