Exemplo n.º 1
0
    // Use this for initialization
    void Awake()
    {
        CharacterController = gameObject.GetComponent("CharacterController") as CharacterController;
        TPMotor = gameObject.GetComponent("ThirdPersonMotor") as ThirdPersonMotor;

        cameraTransform = ThirdPersonCamera.UseExistingOrCreateMainCamera();
    }
Exemplo n.º 2
0
    void OnEnable()
    {
        ThirdPersonMotor motor = (ThirdPersonMotor)target;

        if (motor.gameObject.layer == LayerMask.NameToLayer("Default"))
        {
            PopUpInfoEditor window = ScriptableObject.CreateInstance <PopUpInfoEditor>();
            window.position = new Rect(Screen.width, Screen.height / 2, 360, 100);
            window.ShowPopup();
        }
    }
Exemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        GUI.skin = skin;

        ThirdPersonMotor motor = (ThirdPersonMotor)target;

        if (!motor)
        {
            return;
        }

        GUILayout.BeginVertical("window");

        if (motor.gameObject.layer == LayerMask.NameToLayer("Default"))
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Please assign the Layer of the Character to 'Player'", MessageType.Warning);
        }

        if (motor.groundLayer == 0)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Please assign the Ground Layer to 'Default' ", MessageType.Warning);
        }

        EditorGUILayout.BeginVertical();

        base.OnInspectorGUI();

        GUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        DrawActionController(motor.actionsController);
    }
Exemplo n.º 4
0
    private static void CustomDrawGizmos(Transform aTarget, GizmoType aGizmoType)
    {
#if UNITY_EDITOR
        if (Application.isPlaying)
        {
            ThirdPersonMotor motor = (ThirdPersonMotor)aTarget.GetComponent <ThirdPersonMotor>();
            if (!motor)
            {
                return;
            }

            // debug auto crouch
            Vector3 posHead = motor.transform.position + Vector3.up * ((motor.colliderHeight * 0.5f) - motor.colliderRadius);
            Ray     ray1    = new Ray(posHead, Vector3.up);
            Gizmos.DrawWireSphere(ray1.GetPoint((motor.headDetect - (motor.colliderRadius * 0.1f))), motor.colliderRadius * 0.9f);
            Handles.Label(ray1.GetPoint((motor.headDetect + (motor.colliderRadius))), "Head Detection");
            // debug check trigger action
            Vector3 yOffSet = new Vector3(0f, -0.5f, 0f);
            Ray     ray2    = new Ray(motor.transform.position - yOffSet, motor.transform.forward);
            Debug.DrawRay(ray2.origin, ray2.direction * motor.distanceOfRayActionTrigger, Color.white);
            Handles.Label(ray2.GetPoint(motor.distanceOfRayActionTrigger), "Check for Trigger Actions");
            // debug stopmove
            Ray ray3 = new Ray(motor.transform.position + new Vector3(0, motor.colliderHeight / 3, 0), motor.transform.forward);
            Debug.DrawRay(ray3.origin, ray3.direction * (motor._capsuleCollider.radius + motor.stopMoveDistance), Color.blue);
            Handles.Label(ray3.GetPoint(motor._capsuleCollider.radius + motor.stopMoveDistance), "Check for StopMove");
            // debug slopelimit
            Ray ray4 = new Ray(motor.transform.position + new Vector3(0, motor.colliderHeight / 3.5f, 0), motor.transform.forward);
            Debug.DrawRay(ray4.origin, ray4.direction * 1f, Color.cyan);
            Handles.Label(ray4.GetPoint(1f), "Check for SlopeLimit");
            // debug stepOffset
            Ray ray5 = new Ray((motor.transform.position + new Vector3(0, motor.stepOffsetEnd, 0) + motor.transform.forward * ((motor._capsuleCollider).radius + 0.05f)), Vector3.down);
            Debug.DrawRay(ray5.origin, ray5.direction * (motor.stepOffsetEnd - motor.stepOffsetStart), Color.yellow);
            Handles.Label(ray5.origin, "Step OffSet");
        }
#endif
    }
Exemplo n.º 5
0
 private void OnEnable()
 {
     thirdPersonMotor = (ThirdPersonMotor)target;
     skin             = Resources.Load("GUISkin") as GUISkin;
 }
Exemplo n.º 6
0
 // Use this for initialization
 void Awake()
 {
     rb = GetComponent<Rigidbody>();
     motor = GetComponent<ThirdPersonMotor>();
 }
Exemplo n.º 7
0
 void Awake()
 {
     Instance = this;
 }