Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by VictoryX · Mar 06, 2013 at 08:57 PM · collisioncharactercontrollernotcolliding

Character Controller Collision

My character isn't colliding with objects head on he just walks right through them. If he jumps and lands on them the collision works great he can sit on top of any cube I create it's just when he hits them head on walking forward or backward. The only thing I can think of is how I am moving the controller maybe? Code and controller settings below, any ideas?

Character Controller Settings: Slope Limit = 45, Step Offset = .3, Skin Width = .08, Min Move Distance = 0

 var walkSpeed : float = 5.0;
 var jump : float = 5.0;
 var gravity : float = 9.8;
 var player : GameObject;
 var runSpeed : float = 8.0;
 
 private var jumpNumber : int = 0;
 private var moveDirection = Vector3.zero;
 private var speed : float = 5.0;
 
 
 
 function Update () 
 
 {
     var controller : CharacterController = GetComponent(CharacterController);
     
           
     // Adds Gravity
     moveDirection.y -= gravity * Time.deltaTime;
  
     
     
     // Move the controller
     controller.Move(moveDirection * Time.deltaTime);
 
     
     //Walk Right
     if(Input.GetButton("MoveRight"))
     {
     
         //animation["Walk"].speed = 1.5;
         transform.Translate(Vector3.right * Time.deltaTime * speed);
         
     
     }
     
     
     //Walk Left
     if(Input.GetButton("MoveLeft"))
     {
     
         transform.Translate(Vector3.left * Time.deltaTime * speed);
         
     }
     
     
     //Double Jump
     if(controller.isGrounded)
     {
         jumpNumber = 0;    
     }
     
     
     if(Input.GetButtonDown("Jump") && jumpNumber < 2)
     {
     
         
         moveDirection.y= jump;
         jumpNumber ++;
     
     }
     
     
     //Reset on Death
     if(player.transform.position.y <= -20)
     {
     
     Application.LoadLevel("Squish");
     
     
     }
     
     //Sprint Function
     if(Input.GetButtonDown("Run") && controller.isGrounded)
     {
     
         speed = runSpeed;
     
     
     }
     
     //Sprint Function Release
     if(Input.GetButtonUp("Run"))
     {
     
         speed = walkSpeed;
     
     
     }
     
 
     
     
 }
Comment
Add comment · Show 1
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 LightSource · Mar 07, 2013 at 12:49 AM 0
Share

Check the collider to see if it reaches down to the character controller.

4 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by VictoryX · Mar 07, 2013 at 04:45 AM

I figured out that if I changed

  //Walk Right
 if(Input.GetButton("MoveRight"))
 {
  
 //animation["Walk"].speed = 1.5;
 transform.Translate(Vector3.right * Time.deltaTime * speed);
  
  
 }
  
  
 //Walk Left
 if(Input.GetButton("MoveLeft"))
 {
  
 transform.Translate(Vector3.left * Time.deltaTime * speed);
  
 }


To this

  //Walk Right
 if(Input.GetButtonDown("MoveRight"))
 {
  
 moveDirection.x = speed;
  
  
 }
  
  
 //Walk Left
 if(Input.GetButtonDown("MoveLeft"))
 {
  
 moveDirection.x = -speed;
  
 }

The collision works perfectly fine. So it was the way I was moving my character around that caused it.

Comment
Add comment · Share
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
0

Answer by ManeGuitar123 · Mar 07, 2013 at 01:12 AM

i know that you need to put a mesh collider on components

Comment
Add comment · Show 3 · Share
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 LightSource · Mar 07, 2013 at 01:31 AM 0
Share

Okay, okay, I was just checking. Whats your floor like? Anything special?

avatar image VictoryX · Mar 07, 2013 at 01:44 AM 0
Share

Here's a video link to what the problem is. http://youtu.be/X8tq38HgD2c

avatar image LightSource · Mar 07, 2013 at 01:40 PM 0
Share

Great! Good luck on your project.

avatar image
0

Answer by LightSource · Mar 07, 2013 at 01:59 AM

Try it with a first person character controller (Assets > Import Package > Character Controllers). Are your using the character controller movement script?

If that does not work it a problem with the cube.

If it works it a problem with the collider.

If its a problem with the collider, what I recommend is to change the character controller to the shape you want and retexture it (make it your previous charater). I also see your controllers collider has an unnatural shape, change that to fit the character more securely, it may be conflicting with the cubes box.

If its a problem with the cube, try changing the material and adding a different cube higher above the floor. Also, make sure no scripts are referencing it.

Good luck!

Comment
Add comment · Show 1 · Share
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 VictoryX · Mar 07, 2013 at 04:39 AM 0
Share

I'm using my own movement script which is pretty much a Frankenstein of stuff I find online and help I get here on the forum. I imported the 1st person package and that works/collides fine. I've tried re-shaping the controller collider a bunch of different ways to no effect. I tried adding a mesh collider that would use my models mesh but it won't let me with the character controller on there. How do people use character controllers on their custom characters? The only options for a collider is a capsule shape and a sphere shape on it. $$anonymous$$y only thought is how I'm moving the character in script somehow overrides my collision.

avatar image
0

Answer by MorphVGX · Aug 11, 2015 at 03:10 AM

You should use this: http://docs.unity3d.com/ScriptReference/CharacterController.Move.html

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

13 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

Related Questions

No Collision with character controller 1 Answer

Collision With Character Controller 4 Answers

Colliding with a character controller? 1 Answer

How to avoid Character Controller being launched to the air when colliding? 3 Answers

2.5D platformer main character collision 1 Answer


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