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.
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
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
if you're going for a 'ghost' effect.
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()
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.
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 :)
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
3 People are following this question.
Collision between CharacterControllers on Network
Pixel Perfection collision on 3d animated object
Does OnCollisionEnter only get called when the scripted object initiates the collision?
CharacterController with BoxCollider
Unity3d Arm collision