• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Mr-ex777 · Apr 17, 2016 at 11:07 AM · shootingball

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.

Comment
Add comment · Show 14
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Scribe · Apr 17, 2016 at 01:18 PM 0
Share

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?

avatar image Mr-ex777 Scribe · Apr 17, 2016 at 01:21 PM 0
Share

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.

avatar image Scribe Mr-ex777 · Apr 17, 2016 at 01:49 PM 0
Share

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.

Show more comments
avatar image Scribe · Apr 17, 2016 at 02:15 PM 0
Share

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

avatar image Mr-ex777 Scribe · Apr 17, 2016 at 02:40 PM 0
Share

But i get an error saying "$$anonymous$$ethod must have an return type".

avatar image Scribe Mr-ex777 · Apr 17, 2016 at 02:43 PM 0
Share

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!");
 }
Show more comments
avatar image Scribe · Apr 17, 2016 at 02:56 PM 0
Share

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.

avatar image Mr-ex777 Scribe · Apr 17, 2016 at 02:58 PM 0
Share

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.

avatar image Scribe Mr-ex777 · Apr 17, 2016 at 03:06 PM 0
Share

In rigidbody, set all the rotations to frozen except Y rotation.

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

55 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Best way to animate a shooting-arm on my ball (Player)? 0 Answers

character not moving, though code seems to be right 0 Answers

Shooting Gun Script 4 Answers

Reload only when not firing 1 Answer

Third person controller moving backwards when shooting 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges