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
1
Question by nash · Nov 04, 2011 at 03:44 PM · collisioncharactercontrollercollisiondetection

how to disable characterController's collision detection

can anyone help me? please I need your help anyone, I will really appreciate if someone reply to my question, you are my key to my future

I have a script attached to a cube(the player) a characterController component is attached into it then, I used the "characterController to make it move" it has collision when interacting with other objects

but what I want to happen is to disable or "remove" its collision feature I don't want the cube(the player) to collide to any object "like a ghost that has no collision to anyone".

I also have in mind to make another alternative script to do this to make the character move without the use of a character controller to make it possible

but I know this is the best and fastest way for me to make the character move. my only problem is I don't know to remove its collision detection here is the script that I used please help me.

 using UnityEngine;
 using System.Collections;
 
 public class player : MonoBehaviour
 {
     public static CharacterController CharacterController;
     
     public Vector3 MoveVector;
     public float MoveSpeed = 5f;
     
     void Awake ()
     {        
         CharacterController = GetComponent("CharacterController") as CharacterController;    
 
     }
     
     void Update ()
     {
         
         var deadzone = 0.1f;
         
         MoveVector = Vector3.zero;
         
         if(Input.GetAxis("Vertical") < -deadzone || Input.GetAxis("Vertical") > deadzone)
             MoveVector += new Vector3(0, 0, Input.GetAxis("Vertical"));
         
         if(Input.GetAxis("Horizontal") < -deadzone || Input.GetAxis("Horizontal") > deadzone)
             MoveVector += new Vector3(Input.GetAxis("Horizontal"), 0, 0);        
         
         // Transform MoveVector to Worlds Space3
         MoveVector = transform.TransformDirection(MoveVector);
         
         // Normalize MoveVector  if Magnitude > 1
         if (MoveVector.magnitude > 1)
             MoveVector = Vector3.Normalize(MoveVector);
         
         // multiply MoveVector by MoveSpeed
         MoveVector *= MoveSpeed;
         
         // multiply MoveVector by deltatime
         MoveVector *= Time.deltaTime;
         
         // Move Character in World Space
         CharacterController.Move(MoveVector);
 
 
     }
 }
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by syclamoth · Nov 04, 2011 at 03:47 PM

I'd dispute the "best and fastest" bit. CharacterControllers are notoriously difficult to work with if you aren't doing the (exactly one) thing they're good for, and they come with a significant performance overhead. You'd be better to just use

 transform.Translate(MoveVector);

if you're going for a 'ghost' effect.

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 nash · Nov 04, 2011 at 06:09 PM

ahm sorry for the misunderstanding, I "meant best and fastest" it is the way that I 100% comprehend

actually the code there is from 3dbuzz "third person character setup" if you already heard of it, I Already tried the transform.Translate and removed the characterController, but when I call the function SnapAlignWithCamera() transform.translate fails to convert the local position of the character to world "global position"

here is the code of the SnapAlignWithCamera()

 void SnapAlignCharacterWithCamera()
 {
     if (MoveVector.x != 0 || MoveVector.z != 0)
     {
         transform.rotation = Quaternion.Euler(transform.eulerAngles.x, Camera.mainCamera.transform.eulerAngles.y, transform.eulerAngles.z);
     }
 }

but if I use CharacterController.Move(MoveVector);

it works perfectly

I just want to know if it is possible to disable or remove the collision of the characterController component, if possible how to do it?

thanks for your answer syclamoth I really appreciate it, but I need the exact answer to my question.

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 nash · Nov 04, 2011 at 06:14 PM

sorry I meant best and fastest because when I use this characterController I will just add a couple of line on my code if I already know how to disable the collision on it, rather than change it to transform.translate because I will be forced to change also the other line of codes, that's a lot of work. thanks syclamoth for your answer :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity3d Arm collision 1 Answer

Pixel Perfection collision on 3d animated object 0 Answers

CharacterController with BoxCollider 1 Answer

Collision between CharacterControllers on Network 1 Answer

Collision Problem - Floor Button & Character Controller 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