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);
}
}