Custom character controller, to be used by attaching the component to an object and writing scripts attached to the same object that recieve the "SuperUpdate" message
Inheritance: MonoBehaviour
Exemplo n.º 1
0
        private void Start()
        {
            //Get other RPG Character components.
            superCharacterController    = GetComponent <SuperCharacterController>();
            rpgCharacterController      = GetComponent <RPGCharacterControllerFREE>();
            rpgCharacterInputController = GetComponent <RPGCharacterInputControllerFREE>();
            navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();

            //Check if Animator exists, otherwise pause script.
            animator = GetComponentInChildren <Animator>();
            if (animator == null)
            {
                Destroy(this);
                return;
            }

            //Setup Collider and Rigidbody for collisions.
            capCollider = GetComponent <CapsuleCollider>();
            rb          = GetComponent <Rigidbody>();
            if (rb != null)
            {
                //Set restraints on startup if using Rigidbody.
                rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
            }

            SwitchCollisionOn();

            //Set currentState to idle on startup.
            currentState      = RPGCharacterState.Idle;
            rpgCharacterState = RPGCharacterState.Idle;
        }
    void Start()
    {
        // Put any code here you want to run ONCE, when the object is initialized

        input = gameObject.GetComponent <MegamanInputController>();

        // Grab the controller object from our object
        controller = gameObject.GetComponent <SuperCharacterController>();

        // Our character's current facing direction, planar to the ground
        if (!IsSideScrolling)
        {
            lookDirection = transform.forward;
        }
        else
        {
            lookDirection = transform.right;
        }

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;

        // Keep temporary z position to locking
        spawnPositionZ = transform.position.z;
    }
Exemplo n.º 3
0
        private void Start()
        {
            // Get other RPG Character components.
            superCharacterController = GetComponent <SuperCharacterController>();

            // Check if Animator exists, otherwise pause script.
            animator = GetComponentInChildren <Animator>();
            if (animator == null)
            {
                Debug.LogError("ERROR: THERE IS NO ANIMATOR COMPONENT ON CHILD OF CHARACTER.");
                Debug.Break();
            }
            // Setup Collider and Rigidbody for collisions.
            capCollider = GetComponent <CapsuleCollider>();
            rb          = GetComponent <Rigidbody>();

            // Set restraints on startup if using Rigidbody.
            if (rb != null)
            {
                rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
            }
            rpgCharacterController.OnLockMovement   += LockMovement;
            rpgCharacterController.OnUnlockMovement += UnlockMovement;
            RPGCharacterAnimatorEvents animatorEvents = rpgCharacterController.GetAnimatorTarget().GetComponent <RPGCharacterAnimatorEvents>();

            animatorEvents.OnMove.AddListener(AnimatorMove);
        }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     input = PlayerTarget.GetComponent<PlayerInputController>();
     machine = PlayerTarget.GetComponent<PlayerMachine>();
     controller = PlayerTarget.GetComponent<SuperCharacterController>();
     target = PlayerTarget.transform;
 }
Exemplo n.º 5
0
    private void Awake()
    {
        // Cache input and animator control
        playerInput              = GetComponent <PlayerInput>();
        playerAnimationControl   = GetComponent <PlayerAnimationControl>();
        superCharacterController = GetComponent <SuperCharacterController>();
        // Cache animator and rigidbody
        anim = GetComponent <Animator>();
        rb   = GetComponent <Rigidbody>();
        // Get the camera transform
        m_Cam = playerCamera.transform;

        /*
         * // Get third person character reference
         * m_Character = GetComponent<ThirdPersonCharacter>();
         */
        // Set the current state to idle
        currentState         = CharacterState.Idle;
        playerCharacterState = CharacterState.Idle;

        if (currentItem == CharacterItem.Sword)
        {
            anim.SetInteger("Weapon", 1);
            anim.SetTrigger("WeaponUnsheathTrigger");
        }
        //Idle_EnterState();
        // Make it live!
        isAlive = true;
    }
Exemplo n.º 6
0
        protected override void _StartAction(RPGCharacterController controller, EmptyContext context)
        {
            Collider ladder = controller.ladder;
            SuperCharacterController superCharacterController = movement.GetComponent <SuperCharacterController>();

            float   threshold          = 1f;
            Vector3 ladderTop          = new Vector3(ladder.transform.position.x, ladder.bounds.max.y, ladder.transform.position.z);
            Vector3 ladderBottom       = new Vector3(ladder.transform.position.x, ladder.bounds.min.y, ladder.transform.position.z);
            float   distanceFromTop    = (controller.transform.position - ladderTop).magnitude;
            float   distanceFromBottom = (controller.transform.position - ladderBottom).magnitude;

            // If the top of the ladder is below the character's head, climb onto the top of the ladder.
            if (distanceFromTop < distanceFromBottom && distanceFromTop < threshold)
            {
                movement.ClimbLadder(false);
                controller.ClimbLadder(5);
                movement.currentState = RPGCharacterState.ClimbLadder;
            }
            else if (distanceFromBottom < distanceFromTop && distanceFromBottom < threshold)
            {
                movement.ClimbLadder(true);
                controller.ClimbLadder(6);
                movement.currentState = RPGCharacterState.ClimbLadder;
            }
        }
Exemplo n.º 7
0
 void Start()
 {
     input      = PlayerTarget.GetComponent <PlayerInputController>();
     machine    = PlayerTarget.GetComponent <PlayerMachine>();
     controller = PlayerTarget.GetComponent <SuperCharacterController>();
     target     = PlayerTarget.transform;
 }
    void Start()
    {
        // Put any code here you want to run ONCE, when the object is initialized
        // From UnityChan locomotion script
        // Animatorコンポーネントを取得する
        anim = GetComponent <Animator>();
        // CapsuleColliderコンポーネントを取得する(カプセル型コリジョン)
        col = GetComponent <CapsuleCollider>();
        rb  = GetComponent <Rigidbody>();
        //メインカメラを取得する
        cameraObject = GameObject.FindWithTag("MainCamera");
        // CapsuleColliderコンポーネントのHeight、Centerの初期値を保存する
        orgColHight      = col.height;
        orgVectColCenter = col.center;

        // From PlayerMachine
        input = gameObject.GetComponent <PlayerInputController>();

        // Grab the controller object from our object
        controller = gameObject.GetComponent <SuperCharacterController>();

        // Our character's current facing direction, planar to the ground
        lookDirection = transform.forward;

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;
    }
    // Use this for initialization
    void Start()
    {
        currentDistance = (maxDistance + minDistance) * 0.5f;

        mario      = target.GetComponent <MarioMachine>();
        controller = target.GetComponent <SuperCharacterController>();
        input      = target.GetComponent <MarioInput>();
    }
 // Use this for initialization
 void Start()
 {
     if(m_playerTarget != null)
     {
         input = m_playerTarget.GetComponent<PlayerInputController>();
         machine = m_playerTarget.GetComponent<PlayerMachine>();
         controller = m_playerTarget.GetComponent<SuperCharacterController>();
     }
 }
Exemplo n.º 11
0
 void Start()
 {
     // Put any code here you want to run ONCE, when the object is initialized
     // Grab the controller object from our object
     controller = gameObject.GetComponent <SuperCharacterController>();
     // Our character's current facing direction, planar to the ground
     lookDirection = transform.forward;
     // Set our currentState to idle on startup
     currentState = PlayerStates.Idle;
 }
Exemplo n.º 12
0
    void Awake()
    {
        Collision         = GetComponent <ThirdPersonCameraCollisionHandler>();
        _controller       = PlayerTarget.GetComponent <SuperCharacterController>();
        _target           = PlayerTarget.transform;
        _targetPosition   = _target.position;
        _targetPosition.y = _targetPosition.y + Height;
        _lookDirection    = _target.forward;
        _targetHeightAdjustmentDistance = _targetPosition.y;
        _preTargetHeight = _targetHeightAdjustmentDistance;

        Collision.Initialize(Camera.main);
    }
Exemplo n.º 13
0
    private void Start()
    {
        input = gameObject.GetComponent <PlayerInputController>();

        // Grab the controller object from our object.
        controller = gameObject.GetComponent <SuperCharacterController>();

        // Our character's current facing direction, planar to the ground.
        lookDirection = transform.forward;

        // Set our currentState to idle on startup.
        currentState = PlayerStates.Idle;
    }
	void Start () {
	    // Put any code here you want to run ONCE, when the object is initialized

        input = gameObject.GetComponent<PlayerInputController>();

        // Grab the controller object from our object
        controller = gameObject.GetComponent<SuperCharacterController>();
		
		// Our character's current facing direction, planar to the ground
        lookDirection = transform.forward;

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;
	}
Exemplo n.º 15
0
    void Start()
    {
        player = GameControl.instance.player;

        input = player.GetComponent<PlayerInputController>();
        machine = player.GetComponent<PlayerMachine>();
        controller = player.GetComponent<SuperCharacterController>();
        target = player.transform;

        // Set the look direction based on the initial rotation of the player
        lookDirection = Quaternion.AngleAxis(machine.InitialRotation, controller.up) * Vector3.forward;

        distance = (minDistance + maxDistance) / 2;
    }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        if( Instance == null ){
            Instance = this;
        }else if( Instance != null ){
            Destroy(this);
        }

        input = PlayerTarget.GetComponent<PlayerInputController>();
        machine = PlayerTarget.GetComponent<PlayerMachine>();
        controller = PlayerTarget.GetComponent<SuperCharacterController>();
        target = PlayerTarget.transform;
        onSpin = false;
        continueRotation = 1.0f;
    }
 private void Start()
 {
     superCharacterController = GetComponent <SuperCharacterController>();
     warriorController        = GetComponent <WarriorControllerFREE>();
     warriorInputController   = GetComponent <WarriorInputControllerFREE>();
     animator = GetComponentInChildren <Animator>();
     rb       = GetComponent <Rigidbody>();
     if (rb != null)
     {
         //Set restraints on startup if using Rigidbody.
         rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
     }
     //Set currentState to idle on startup.
     currentState = WarriorState.Idle;
     warriorState = WarriorState.Idle;
     SwitchCollisionOn();
 }
Exemplo n.º 18
0
 void Awake()
 {
     superCharacterController    = GetComponent <SuperCharacterController>();
     rpgCharacterController      = GetComponent <RPGCharacterControllerFREE>();
     rpgCharacterInputController = GetComponent <RPGCharacterInputController>();
     navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();
     animator     = GetComponentInChildren <Animator>();
     rb           = GetComponent <Rigidbody>();
     if (rb != null)
     {
         //Set restraints on startup if using Rigidbody.
         rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
     }
     //Set currentState to idle on startup.
     currentState      = RPGCharacterState.Idle;
     rpgCharacterState = RPGCharacterState.Idle;
 }
    void Start()
    {
        currentCameraPosition = InitialPosition;

        target = GameObject.FindWithTag("Player").transform;

        input      = target.GetComponent <MarioInput>();
        mario      = target.GetComponent <MarioMachine>();
        controller = target.GetComponent <SuperCharacterController>();

        currentRotationHorizontal = mario.InitialRotation;

        var height = Mathf.Lerp(MinHeight, MaxHeight, currentCameraPosition);

        verticalPosition = Math3d.ProjectPointOnLine(Vector3.zero, controller.up, target.position + height * controller.up);

        StartCoroutine(ConstantShake());
    }
Exemplo n.º 20
0
    void Start()
    {
        FireOrigin.Stop();
        // Put any code here you want to run ONCE, when the object is initialized
        inputDecay = 0f;

        input = gameObject.GetComponent <PlayerInputController>();

        // Grab the controller object from our object
        controller = gameObject.GetComponent <SuperCharacterController>();

        // Our character's current facing direction, planar to the ground
        lookDirection = transform.forward;

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;

        animator = gameObject.GetComponent <Animator> ();

        defaultGravity = Gravity;
    }
Exemplo n.º 21
0
    protected virtual void Start()
    {
        Alive = true;

        controller = gameObject.GetComponent <SuperCharacterController>();

        lookDirection = transform.forward;

        if (RandomDirection)
        {
            lookDirection = Quaternion.AngleAxis(UnityEngine.Random.Range(0f, 360f), transform.up) * lookDirection;
        }

        anim = AnimatedMesh.GetComponent <Animation>();

        playerLayer = 1 << LayerMask.NameToLayer("Player");

        if (!target)
        {
            target = GameObject.FindWithTag("Player").transform;
        }
    }
    void Start()
    {
        Cursor.visible = false;
        input          = gameObject.GetComponent <PlayerInputController>();

        // Grab the controller object from our object
        controller = gameObject.GetComponent <SuperCharacterController>();

        // Our character's current facing direction, planar to the ground
        lookDirection = transform.forward;

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;

        originalWalkspeed            = WalkSpeed;
        extraWallRunSpeed            = WalkSpeed * 1.75f;
        extraWallRunJumpAcceleration = JumpAcceleration * 2f;
        originalWalkAcceleration     = WalkAcceleration;
        originalJumpAcceleration     = JumpAcceleration;
        reducedJumpAcceleration      = JumpAcceleration / 10f;
        originalGravity = Gravity;
        wallRunGravity  = originalGravity / 2;
    }
Exemplo n.º 23
0
 void Start()
 {
     player    = FindObjectOfType <SuperCharacterController> ();
     inputs    = FindObjectOfType <PlayerInputController> ();
     collDetec = FindObjectOfType <ColDetector> ();
 }
Exemplo n.º 24
0
 void Start()
 {
     player = FindObjectOfType <SuperCharacterController> ();
 }
 public SuperGround(LayerMask walkable, SuperCharacterController controller, QueryTriggerInteraction triggerInteraction)
 {
     this.walkable           = walkable;
     this.controller         = controller;
     this.triggerInteraction = triggerInteraction;
 }
Exemplo n.º 26
0
 void Start()
 {
     target     = mario.transform;
     controller = mario.GetComponent <SuperCharacterController>();
     projector  = GetComponent <Projector>();
 }
 public SuperGround(LayerMask walkable, SuperCharacterController controller)
 {
     this.walkable = walkable;
     this.controller = controller;
 }
Exemplo n.º 28
0
    void Start()
    {
        controller = gameObject.GetComponent<SuperCharacterController>();
        input = gameObject.GetComponent<PlayerInputController>();
        cam = GameControl.instance.mainCamera.GetComponent<PlayerCamera>();
        anim = AnimatedMesh.GetComponent<Animator>();

        // Our character's current facing direction, planar to the ground
        artForwardDirection = Quaternion.AngleAxis(InitialRotation, controller.up) * Vector3.forward;
        artUpDirection = controller.up;
        AnimatedMesh.rotation = Quaternion.LookRotation (artForwardDirection, artUpDirection);

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;

        RunSpeed = MoveSpeed * 0.4f;
        RunSmokeEffect.enableEmission = false;
        doubleJump = false;
    }
Exemplo n.º 29
0
        private void Awake()
        {
            // Get SuperCharacterController.
            superCharacterController = GetComponent <SuperCharacterController>();

            // Get Movement Controller.
            warriorMovementController = GetComponent <WarriorMovementController>();

            // Add Timing Controllers.
            warriorTiming = gameObject.AddComponent <WarriorTiming>();
            warriorTiming.warriorController = this;

            // Add IKHands.
            ikHands = GetComponentInChildren <IKHands>();
            if (ikHands != null)
            {
                if (warrior == Warrior.TwoHanded ||
                    warrior == Warrior.Hammer ||
                    warrior == Warrior.Crossbow ||
                    warrior == Warrior.Spearman)
                {
                    ikHands.canBeUsed = true;
                    ikHands.BlendIK(true, 0, 0.25f);
                }
            }

            // Setup Animator, add AnimationEvents script.
            animator = GetComponentInChildren <Animator>();
            if (animator == null)
            {
                Debug.LogError("ERROR: There is no Animator component for character.");
                Debug.Break();
            }
            else
            {
                animator.gameObject.AddComponent <WarriorCharacterAnimatorEvents>();
                animator.GetComponent <WarriorCharacterAnimatorEvents>().warriorController = this;
                animator.gameObject.AddComponent <AnimatorParentMove>();
                animator.GetComponent <AnimatorParentMove>().animator          = animator;
                animator.GetComponent <AnimatorParentMove>().warriorController = this;
                animator.updateMode  = AnimatorUpdateMode.AnimatePhysics;
                animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
            }

            // Determine input source.
            warriorInputController = GetComponent <WarriorInputController>();
            if (warriorInputController != null)
            {
                useInputSystem = false;
            }
            else
            {
                warriorInputSystemController = GetComponent <WarriorInputSystemController>();
                if (warriorInputSystemController != null)
                {
                    useInputSystem = true;
                }
                else
                {
                    Debug.LogError("No inputs!");
                }
            }

            // Setup Rigidbody.
            rb = GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
            }

            currentState = WarriorState.Idle;
        }
Exemplo n.º 30
0
    void Start()
    {
        // Put any code here you want to run ONCE, when the object is initialized
        weaponList = new IWeapon[]{ new NetBehaviour( gameObject,hittable ), new SwordBehaviour(gameObject,hittable) };
        mWeapon = weaponList[0];
        input = gameObject.GetComponent<PlayerInputController>();
        anims = new AnimState[]{ new idleAnimState(),new runAnimState(),new jumpAnimState(),new doubleJumpAnimState(),new climbAnimState(),new fallAnimState() };
        currentAnimState = anims[0];
        // Grab the controller object from our object
        controller = gameObject.GetComponent<SuperCharacterController>();

        // Our character's current facing direction, planar to the ground
        lookDirection = transform.forward;

        // Set our currentState to idle on startup
        currentState = PlayerStates.Idle;
    }
Exemplo n.º 31
0
 public SuperGround(LayerMask walkable, SuperCharacterController controller)
 {
     this.walkable   = walkable;
     this.controller = controller;
 }
Exemplo n.º 32
0
 void Start()
 {
     sCC = GetComponent <SuperCharacterController>();
 }
 public SuperGround(LayerMask walkable, SuperCharacterController controller, QueryTriggerInteraction triggerInteraction)
 {
     this.walkable = walkable;
     this.controller = controller;
     this.triggerInteraction = triggerInteraction;
 }