Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Meater6 · Jun 13, 2011 at 11:28 PM · collisioncharactercontrollermovemerge

CC Collisions, Locking Y Axis

Hi UA users. I have a problem where I have a character controller on each enemy and they move toward my player to attack (they use the move function if its helpful). The movement works fine but when they collide with each other they ride on top of each other. I tried locking the Y axis, but then they occasionally "merge" with each other. There was already a question on this merging, but its answers just recommended not using CCs. In this game I have no other option. I don't want to disable collisions between the enemies either. There was one GAME for unity that seems to have solved this problem. If you notice, the tanks have the movement and collisions like with CCs. So how can I remove either the riding or the merging?

Here's my script:

 var speed : float = 2;
 var target : Transform;
 var stopRadius : float = 1;
 var height : float = 2;
 
 private var moveDirection : Vector3;
 
 function FixedUpdate () {
 
     var controller : CharacterController = GetComponent("CharacterController");
     
     if(controller && target){
         var distance : float = Vector3.Distance(target.position,transform.position);
         if(distance >= stopRadius) {
             moveDirection = target.position - transform.position;
             moveDirection = Vector3.Normalize(moveDirection);
             moveDirection.y = 0;
             moveDirection *= speed;
         }
         else{
             moveDirection = Vector3.zero;
         }
         controller.Move(moveDirection * Time.deltaTime);
         
         transform.position.y = height;
         
         transform.LookAt(Vector3(target.position.x,transform.position.y,target.position.z));
     }
 
 }

Thanks for responding.

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

1 Reply

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

Answer by Chris D · Jun 13, 2011 at 11:36 PM

Looking at the character controller docs:

http://unity3d.com/support/documentation/Components/class-CharacterController.html

What are your skin widths and step offsets set to? How large are your enemies? Play around with them a bit and see if that fixes it.

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 Meater6 · Jun 13, 2011 at 11:43 PM 0
Share

Ok, Found 2 ways to do it. Lock the y axis and increase the skin width, or add gravity and decrease the step offset. Thanks so much, this has been a long problem. :)

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

2 People are following this question.

avatar image avatar image

Related Questions

Disable collision between mesh collider and character controller 3 Answers

Voxel engine physics 3rd person character controller 1 Answer

How to deal the 2d platform physics? 0 Answers

My Character controller is being push a little bit when i'm about the get the coins. How can i possibly detect collision and destroy the coins without actually getting affected by the colliding physics? 1 Answer

Death Condition ?? 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