示例#1
1
 // Use this for initialization
 void Start()
 {
     inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
     playerController = this.GetComponent<ThirdPersonCharacter> ();
     player = GameObject.FindGameObjectWithTag("Player");
     playerModel = GameObject.FindGameObjectWithTag ("PlayerModel");
 }
	private void Start()
	{
		// get the transform of the main camera
		if (Camera.main != null)
		{
			m_Cam = Camera.main.transform;
		}
		else
		{
			Debug.LogWarning(
				"Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
			// we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
		}
		
		// get the third person character ( this should never be null due to require component )
		m_Character = GetComponent<ThirdPersonCharacter>();


		m_PhotonView = GetComponent<PhotonView>();
		gameObject.name = gameObject.name + m_PhotonView.viewID;


		if (m_PhotonView.isMine) {
			//GameObject camera = PhotonNetwork.Instantiate ("FreeCamera", new Vector3 (0f, 1f, 0f), Quaternion.identity, 0);
			//camera.name = "freeCamera";

			//GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<FreeLookCamera> ().SetTarget (gameObject.transform);
			FreeLookCamera cam = FindObjectOfType (typeof(FreeLookCamera)) as FreeLookCamera;
			cam.SetTarget(gameObject.transform);
		}
	}
示例#3
0
 protected void Start()
 {
     agent = GetComponentInChildren<NavMeshAgent>();
     character = GetComponent<ThirdPersonCharacter>();
     agent.updateRotation = false;
     agent.updatePosition = true;
 }
	// Use this for initialization
	void Start () {

        // get the components on the object we need ( should not be null due to require component so no need to check )
		agent = GetComponentInChildren<NavMeshAgent>();
		character = GetComponent<ThirdPersonCharacter>();

	}
    void Start()
    {
        agent = GetComponent<NavMeshAgent>();
        character = GetComponent<ThirdPersonCharacter>();

        _machine = new SKStateMachine<EnemyAIController>(this, new EnemyAIPatrol());
        _machine.addState(new EnemyAIChase());
    }
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    void Start()
    {
        snowball = Resources.Load ("Snow Ball") as GameObject;
        attachedBodyPart = gameObject;
        cameraState = 0;

        pController = GameObject.Find("ThirdPersonController").GetComponent<ThirdPersonCharacter>();
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        god = GameObject.FindGameObjectWithTag("God").GetComponent<God>();
        animator = GetComponentInChildren<Animator>();
        character = GetComponentInChildren<ThirdPersonCharacter>();

        m_Cam = Camera.main.transform;
    }
    // Use this for initialization
    void Start()
    {
        // get the transform of the main camera
        cam = Camera.main.transform;

        // get the third person character ( this should never be null due to require component )
        character = GetComponent<ThirdPersonCharacter>();
    }
示例#9
0
 void Awake()
 {
     if(_animator == null)
         _animator = GetComponent<Animator>();
     
     _aiController = GetComponent<AICharacterControl>();
     _thirdPersonController = GetComponent<ThirdPersonCharacter>();
     _characterController = GetComponent<CharacterController>();
 }
示例#10
0
        public Transform target; // target to aim for

        // Use this for initialization
        private void Start()
        {
            // get the components on the object we need ( should not be null due to require component so no need to check )
            agent = GetComponentInChildren<NavMeshAgent>();
            character = GetComponent<ThirdPersonCharacter>();

	        agent.updateRotation = false;
	        agent.updatePosition = true;
        }
    private void Start()
    {
        if (Camera.main != null)
        {
            m_CamObject = Camera.main.transform;
        }

        m_Character = GetComponent<ThirdPersonCharacter>();
        InputManager.ButtonPress += HandleInput;
    }
示例#12
0
 void Awake()
 {
     anim = GetComponent <Animator> ();
     playerAudio = GetComponent <AudioSource> ();
     playerMovement = GetComponent <ThirdPersonCharacter> ();
     //playerShooting = GetComponentInChildren <PlayerShooting> ();
     currentHealth = startingHealth;
     HealthSliderStatus(currentHealth);
     //healthSlider.value = currentHealth;
     playerInterction = GetComponent <PlayerInteraction> ();
 }
示例#13
0
	// Use this for initialization
	void Start () {
		Messenger.AddListener<bool>("lock player input", lockInput);
		Messenger.AddListener<bool>("set is poisoned", setIsPoisoned);
		// get the transform of the main camera
		if (Camera.main) {
			r_Camera = Camera.main.transform;
		} else {
			Debug.LogWarning("Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
			// we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
		}
		
		r_Character = GetComponent<ThirdPersonCharacter>();	
	}
示例#14
0
	// Use this for initialization
	void Start () {
		r_Character = GetComponent<ThirdPersonCharacter>();
		if (mTargets.Count != 0) {
			if (gameObject.GetComponent<ThirdPersonController>()!=null) {
				gameObject.GetComponent<ThirdPersonController>().enabled = false;
			}
		}
		if (Camera.main) {
			r_Camera = Camera.main.transform;
		} else {
			Debug.LogWarning("Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
			// we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
		}
	}
    // Use this for initialization
    void Start()
    {
        // get the transform of the main camera
        if (Camera.main != null)
        {
            cam = Camera.main.transform;
        } else {
            Debug.LogWarning("Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
            // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
        }

        // get the third person character ( this should never be null due to require component )
        character = GetComponent<ThirdPersonCharacter>();
    }
        private void GetComponents()
        {
            // get the transform of the main camera
            if (Camera.main != null)
            {
                m_Cam = Camera.main.transform;
            }
            else
            {
                Debug.LogWarning(
                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject);
                // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
            }

            // get the third person character ( this should never be null due to require component )
            m_Character = GetComponent <ThirdPersonCharacter>();
        }
示例#17
0
    private void Awake()
    {
        _thirdPersonCharacter = GetComponent <ThirdPersonCharacter>();
        _userControl          = GetComponent <ThirdPersonUserControl>();
        _rigidbody            = GetComponent <Rigidbody>();
        _animator             = GetComponent <Animator>();

        ;
        _materialPropertyBlocks = new MaterialPropertyBlock[_skinnedMeshRenderers.Length];
        for (int i = 0; i < _skinnedMeshRenderers.Length; i++)
        {
            _materialPropertyBlocks[i] = new MaterialPropertyBlock();
            _skinnedMeshRenderers[i].SetPropertyBlock(_materialPropertyBlocks[i]);
            _materialPropertyBlocks[i].SetColor("_Color", Color.white);
            _skinnedMeshRenderers[i].SetPropertyBlock(_materialPropertyBlocks[i]);
        }
    }
示例#18
0
    public void Init()
    {
        //initialize DNA
        //0 forward
        //1 backward
        //2 left
        //3 right
        //4 jump
        //5 crouch
        dna         = new DNA(DNALength, numActions);
        m_Character = GetComponent <ThirdPersonCharacter>();
        timeAlive   = 0;
        alive       = true;

        distanceTravelled = 0;
        initialPosition   = gameObject.transform.position;
    }
示例#19
0
    public void RunThroughOpponents(King k, int first, int last)
    {
        k.IsInCheck     = false;
        k.IsInCheckMate = false;

        int index = chessPieces.IndexOf(k);

        Debug.Log(index);
        ThirdPersonCharacter king = gamePieces[index].GetComponent <ThirdPersonCharacter>();
        Pair p = GetPairInGrid(king.boardPosition, grid.Positions);

        for (int i = first; i < last; i++)
        {
            ThirdPersonCharacter ethan = gamePieces[i].GetComponent <ThirdPersonCharacter>();
            //update movables and attackables
            chessPieces[i].CheckSurroundings(ethan.boardPosition, piecesPositions, grid.Positions, GamePieces);
            //check if king belongs to attackables
            if (chessPieces[i].attackableSpots.Contains(p))
            {
                k.IsInCheck = true;
                break;
            }
            //countMovesAroundKing++;
            //check if king surroundings belong to movables
            //foreach (Pair item in chessPieces[i].movableSpots)
            //{
            //    foreach (Pair pp in k.possibleChecks)
            //    {
            //        if (item.Equals(pp))
            //            countMovesAroundKing++;
            //    }
            //}
        }

        //if (countMovesAroundKing > 0)
        //    k.IsInCheck = true;
        //if (countMovesAroundKing >= k.countOfPossibleChecks)
        //{
        //    k.IsInCheckMate = true;
        //    //stop game
        //    string message = "Check mate!";
        //    //message += k.Layer + "lost";
        //    gameOver(message);
        //}
    }
示例#20
0
    private void Start()
    {
        // Search for the script that inherit from IEnemyAttack to attack
        enemyAttack = GetComponent <IEnemyAttack>();

        rb           = GetComponent <Rigidbody>();
        playerHealth = player.GetComponent <PlayerHealth>();

        enemyHealth = GetComponent <EnemyHealth>();

        // Set the reference of NavMeshAgent
        agent = GetComponent <NavMeshAgent>();
        agent.updateRotation = false;

        character = GetComponent <ThirdPersonCharacter>();

        // Set destination so the enemy can move there
    }
示例#21
0
    void Start()
    {
        // state = State.LEAVE;
        // GameObject god = GameObject.Find("God");
        // God godScript = god.GetComponent<God>();
        // God.startRitual += new EventHandler(Pray);
        state = State.WANDER;
        outerPoint = GameObject.Find("OuterPoint");
        map = GameObject.Find("map");
        mapCollider = map.GetComponent<Collider>();

        navMeshAgent = GetComponent<NavMeshAgent>();
        character = GetComponent<ThirdPersonCharacter>();
        characterControl = GetComponent<AICharacterControl>();

        StartCoroutine(GetTargetLoop(UnityEngine.Random.Range(1f, 2f) * 2f));
        StartCoroutine(IAStateMachine());
    }
示例#22
0
 // Use this for initialization
 void Start()
 {
     agent                = this.GetComponent <NavMeshAgent>();
     character            = this.GetComponent <ThirdPersonCharacter>();
     agent.updateRotation = false;
     if (agent != null)
     {
         if (patrolPoints != null && patrolPoints.Count >= 2)
         {
             currentPatrolIndex = 0;
             SetDestination();
         }
     }
     else
     {
         Debug.LogError("insert navmeshAgent to" + gameObject.name);
     }
 }
示例#23
0
    public void Init()
    {
        //initialise DNA
        //0 forward
        //1 back
        //2 left
        //3 right
        //4 jump
        //5 crouch
        dna         = new DNA(DNALength, 6); //make dna with random int values within control schema
        m_Character = GetComponent <ThirdPersonCharacter>();
        timeAlive   = 0;
        alive       = true;

        #region Adam Edit
        startingPosition = transform.position;
        #endregion
    }
示例#24
0
    public void UpdateAttacks(GameObject selectedPiece, GameController gc)
    {
        ThirdPersonCharacter ethan = selectedPiece.GetComponent <ThirdPersonCharacter>();

        //clear out lists
        ethan.attackPositions.Clear();

        //copy the attackables to list
        for (int i = 0; i < attackableSpots.Count; i++)
        {
            Pair   pair = attackableSpots[i];
            string a    = gc.grid.Positions[pair.Z, pair.X];
            ethan.attackPositions.Add(a);
        }

        //movableSpots.Clear();
        //attackableSpots.Clear();
    }
    /// <summary>
    /// To be called when we create the prefab rfom the Population Manager
    /// </summary>
    public void Init()
    {
        ///<see cref="DNA.genes"/>
        //initialise DNA
        // 0 forward
        // 1 back
        // 2 left
        // 3 right
        // 4 jump
        // 5 crouch

        dna = new DNA(DNALength, 6);

        m_Character   = GetComponent <ThirdPersonCharacter>();
        startPosition = transform.position;
        timeAlive     = 0;
        alive         = true;
    }
示例#26
0
 // Use this for initialization
 void Start()
 {
     tpc = GetComponentInParent <ThirdPersonCharacter> ();
     Debug.Log(tpc.gameObject.name);
     anim               = GetComponent <Animator> ();
     audio_source       = GetComponent <AudioSource> ();
     audio_source.pitch = 0.65f;
     foreach (AnimationClip i in anim.runtimeAnimatorController.animationClips)
     {
         //Debug.Log ("apprentspeed " + i.apparentSpeed + i.name);
         //Debug.Log ("averagespeed " + i.averageSpeed + i.);
         if (i.name == "CandleWalk")
         {
             animationlength = i.length;
         }
     }
     //foreach(AnimationState i in anim.runtimeAnimatorController
 }
示例#27
0
    private Piece CreatePieces(Transform child)
    {
        string tag   = child.tag;
        int    layer = child.gameObject.layer;
        ThirdPersonCharacter ethan = child.GetComponent <ThirdPersonCharacter>();

        Piece piece;

        switch (tag)
        {
        case "Pawn":
            piece = new Pawn(layer);
            break;

        case "Knight":
            piece = new Knight(layer);
            break;

        case "Queen":
            piece = new Queen(layer);
            break;

        case "Bishop":
            piece = new Bishop(layer);
            break;

        case "Rook":
            piece = new Rook(layer);
            break;

        case "King":
            piece = new King(layer);
            kings.Add(piece);
            break;

        default:
            piece = null;
            break;
        }

        ethan.pieceType = piece;

        return(piece);
    }
示例#28
0
    public override void Start()
    {
        GameObject interactables;

        EventCounter     = 0;
        CurrentEventType = 0;

        // Set the filePath and init the network
        FilePath = Path.Combine(Application.streamingAssetsPath, "NeedsNetwork.nn");
        base.Start();

        // Get components
        Anim    = GetComponent <Animator>();
        AIAgent = GetComponent <NavMeshAgent>();

        interactables = GameObject.FindGameObjectWithTag("interactables");
        Objects       = interactables.GetComponentsInChildren <Interactable>();
        TPController  = GetComponent <ThirdPersonCharacter>();
    }
示例#29
0
        void Start()
        {
            character  = GetComponent <ThirdPersonCharacter>();
            raycaseter = Camera.main.GetComponentInParent <CameraRaycaster>();
            nav        = GetComponent <NavMeshAgent>();

            stopDistance       = nav.stoppingDistance;
            nav.updateRotation = false;
            nav.updatePosition = true;

            destination = transform.position;
            gizmoDest   = gizmoRecentD = destination;

            if (raycaseter != null)
            {
                raycaseter.OnMouseOverPotentiallyWalkable += OnMouseClickToMove; // observer
                raycaseter.OnMouseOverEnemy += OnMouseClickToEnemy;
            }
        }
示例#30
0
 void Awake()
 {
     if (movementController == null)
     {
         movementController = GetComponent <ThirdPersonCharacter>();
     }
     if (swordController == null)
     {
         swordController = GetComponent <SwordAIControl>();
     }
     if (thisObjectToHit == null)
     {
         thisObjectToHit = GetComponent <ObjectToHit>();
     }
     if (agent == null)
     {
         agent = GetComponent <NavMeshAgent>();
     }
 }
示例#31
0
 void Awake()
 {
     if (movementController == null)
     {
         movementController = GetComponent<ThirdPersonCharacter>();
     }
     if (swordController == null)
     {
         swordController = GetComponent<SwordAIControl>();
     }
     if (thisObjectToHit == null)
     {
         thisObjectToHit = GetComponent<ObjectToHit>();
     }
     if (agent == null)
     {
         agent = GetComponent<NavMeshAgent>();
     }
 }
        // Use this for initialization
        void Start()
        {
            dc = FindObjectOfType <DialogueController>();
            collidingActors = new List <Actor>();

            // get the transform of the main camera
            if (Camera.main != null)
            {
                Cam = Camera.main.transform;
            }
            else
            {
                Debug.LogWarning(
                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject);
            }
            // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!

            Character = GetComponent <ThirdPersonCharacter>();
        }
示例#33
0
        void Awake()
        {
            if (agent == null)
            {
                Debug.LogWarning("You don't set any agent in CharacterActuator.");
            }
            // get the third person character ( this should never be null due to require component )
            character = agent.GetComponent <ThirdPersonCharacter>();

            if (mainCamera != null)
            {
                m_CamTransform = mainCamera.transform;
            }
            else
            {
                Debug.LogWarning(
                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject);
                // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
            }
        }
示例#34
0
    private void Start()
    {
        gm = GameObject.Find("GameManager").GetComponent <GameManager>();
        // get the transform of the main camera
        if (Camera.main != null)
        {
            m_Cam = Camera.main.transform;
        }
        else
        {
            Debug.LogWarning(
                "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject);
            // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
        }

        // get the third person character ( this should never be null due to require component )
        m_Character = GetComponent <ThirdPersonCharacter>();
        gm.EventMan.stopPlayer.AddListener(StopPlayer);
        gm.EventMan.movePlayerToPosition.AddListener(StartMoveToPosition);
    }
示例#35
0
    // Update is called once per frame
    void Start()
    {
        player           = this.gameObject;
        battle_transform = transform.parent;

        //Physics.gravity = new Vector3(0, -9.81F, 0);
        GravityDrctInBattleWorld = new Vector3(0, -9.81F, 0);
        Physics.gravity          = GravityDrctInBattleWorld;
        originGravityDrct        = Physics.gravity;
        targetGravityDrct        = Physics.gravity;
        tpc = player.GetComponent <ThirdPersonCharacter>();
        if (mainCamera_transform == null)
        {
            mainCamera_transform = GameObject.FindGameObjectWithTag("MainCamera").transform;
        }
        battleControlCentor = GameObject.FindGameObjectWithTag("Battle").GetComponent <BattleControlCenter>();

        plrCapsule = gameObject.GetComponent <CapsuleCollider>();
        //dsada
    }
示例#36
0
    public override void Start()
    {
        // Set the filePath and init the network
        FilePath = Path.Combine(Application.streamingAssetsPath, "MasterNetwork.nn");
        base.Start();

        AIAgent      = GetComponent <NavMeshAgent>();
        TPController = GetComponent <ThirdPersonCharacter>();
        Anim         = GetComponent <Animator>();
        Stats        = GetComponent <CharacterStats>();

        // Add Behaviors
        NController = GetComponent <NeedsController>();

        AIAgent.updateRotation = false;

        // Subscribe to event manager events
        EventManager.instance.HitEvent   += OnHitEvent;
        EventManager.instance.DeathEvent += OnDeathEvent;
    }
示例#37
0
    private bool m_Jump;                      // the world-relative desired move direction, calculated from the camForward and user input.

    void Start()
    {
        mCamera = GameObject.Find("FreeLookCameraRig").GetComponent <FreeLookCam>();
        mCamera.SetTarget(transform);

        // get the transform of the main camera
        if (Camera.main != null)
        {
            m_Cam = Camera.main.transform;
        }
        else
        {
            Debug.LogWarning(
                "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
            // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
        }

        // get the third person character ( this should never be null due to require component )
        m_Character = GetComponent <ThirdPersonCharacter>();
    }
示例#38
0
    private void Start()
    {
        if (Camera.main == null)
        {
            Debug.LogWarning(
                "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\"," +
                " for camera-relative controls.", gameObject);
        }

        this.thirdPersonCharacter = GetComponent <ThirdPersonCharacter>();
        //transform.position = Vector3.zero;
        //this.shortenedClickPoint = Vector3.zero;
        this.shortenedClickPoint = transform.position;

        //rayCaster = FindObjectOfType<CameraRaycaster>();
        this.rayCaster = Camera.main.GetComponent <CameraRaycaster1>();

        // register with the CameraRaycaster that we are listening to layer hit changes
        this.rayCaster.OnHitItemChangeObservers += OnHitItemChanged;
    }
示例#39
0
    IEnumerator DominosFall()
    {
        ThirdPersonCharacter p    = GameObject.FindGameObjectWithTag("Player").GetComponent <ThirdPersonCharacter>();
        Quaternion           look = Camera.main.transform.localRotation;
        Vector3 camLoc            = Camera.main.transform.localPosition;

        Camera.main.transform.parent        = transform;
        Camera.main.transform.localPosition = new Vector3(0, 20, 0);
        Camera.main.transform.localRotation = Quaternion.LookRotation(transform.position - Camera.main.transform.position);
        p.enabled = false;
        yield return(new WaitForSeconds(12));

        b.fall = true;
        yield return(new WaitForSeconds(3));

        p.enabled = true;
        Camera.main.transform.parent        = p.transform;
        Camera.main.transform.localPosition = camLoc;
        Camera.main.transform.localRotation = look;
    }
示例#40
0
    public void Setup()
    {
        m_actor            = m_Instance.GetComponent <ThirdPersonCharacter>();
        m_Movement         = m_Instance.GetComponent <ThirdPersonUserControl>();
        m_Shooting         = m_Instance.GetComponent <Shooting>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

        m_actor.m_PlayerNumber    = m_PlayerNumber;
        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_PlayerNumber = m_PlayerNumber;

        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = m_PlayerColor;
        }
    }
示例#41
0
    // Start is called before the first frame update
    void Start()
    {
        Maria            = GetComponent <ThirdPersonCharacter>();
        particleTimer    = Time.deltaTime;
        m_Animator       = GetComponent <Animator>();
        m_Rigidbody      = GetComponent <Rigidbody>();
        m_Capsule        = GetComponent <CapsuleCollider>();
        particle         = this.GetComponentInChildren <ParticleSystem>().emission;
        particle.enabled = false;
        isEnemy          = false;
        swordCol         = GameObject.Find("SwordCol");
        swordCol.SetActive(false);
        hasSword = false;

        numOfClicks = 0;
        countClicks = 0;
        canClick    = true;

        timer = Time.deltaTime;
    }
示例#42
0
    // Update is called once per frame
    public void Init()
    {
        TotalDistance = Vector2.Distance(transform.position, Target);



        // Intialize DNA
        //0 forward
        //1 back
        //2 left
        //3 right
        //4 jump
        //5 crouch

        dna = new DNA(DNALength, 6);

        m_Character = GetComponent <ThirdPersonCharacter>();
        timeAlive   = 0;
        alive       = true;
    }
    //private int uiDisable;

    private void Start()
    {
        PlayerPrefs.SetFloat(mushroomdirection, 0);
        //            // get the transform of the main camera
        //            if (Camera.main != null)
        //            {
        //                m_Cam = Camera.main.transform;
        //            }
        //            else
        //            {
        //                Debug.LogWarning(
        //                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
        //                // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
        //            }

        // get the third person character ( this should never be null due to require component )
        m_Character = GetComponent <ThirdPersonCharacter>();

        walkStick = this.ctrl.GetStick(STICK_WALK);
    }
示例#44
0
        private void Start()
        {
            if (Camera.main == null)
            {
                Debug.LogWarning(
                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\"," +
                    " for camera-relative controls.", gameObject);
            }

            this.thirdPersonCharacter = GetComponent <ThirdPersonCharacter>();
            this.aiController         = GetComponent <AICharacterControl>();
            this.navMeshAgent         = GetComponent <NavMeshAgent>();
            this.rayCaster            = Camera.main.GetComponent <CameraRaycaster>();


            // register with the CameraRaycaster that we are listening to layer hit changes
            this.rayCaster.notifyMouseClickObservers += OnHitItemChanged;

            // start off in indirect mode
            this.isInDirectMode = true;
        }
示例#45
0
    private void OnEnable()
    {
        if (Unit == null)
        {
            Unit = GetComponent <Unit>();
        }
        if (_cam == null && Camera.main != null)
        {
            _cam = Camera.main.transform;
        }
        if (_character == null)
        {
            _character = GetComponent <ThirdPersonCharacter>();
        }
        if (_animator == null)
        {
            _animator = GetComponent <Animator>();
        }

        _character.enabled = true;
    }
    // Use this for initialization
	void Start () {
        s_score = 0;
        s_gameover = false;
        m_hit = false;
        m_controller = GetComponent<ThirdPersonCharacter>();
        m_animator = GetComponent<Animator>();
        m_audio = gameObject.GetComponent<AudioSource>();
        m_stage = GameObject.FindGameObjectWithTag(m_StageTag).GetComponent<StageBuilder>();

        if (!m_controller) {
            m_animator.SetFloat("direction", -1.0f);
        }
        m_foots = new Transform[m_Foots.Length];
        m_footYs = new float[m_Foots.Length];
        for (var i = 0; i < m_Foots.Length; i++) {
            m_foots[i] = searchTransform(transform, m_Foots[i]);
            m_footYs[i] = m_foots[i].position.y;
        }
        m_offset = Vector3.zero;
        transform.position = m_offset;
	}
示例#47
0
    // Use this for initialization
    void Start()
    {
        //pauseManager = FindObjectOfType<PauseManager>();

        placed_target = Instantiate(target, new Vector3(transform.position.x, 0.64f, transform.position.z), new Quaternion(0, 0, 0, 0));
        hover_target  = Instantiate(transparentTarget, new Vector3(transform.position.x, 0.64f, transform.position.z), new Quaternion(0, 0, 0, 0));
        placed_target.SetActive(false);
        hover_target.SetActive(false);

        agent       = GetComponent <NavMeshAgent>();
        cam         = FindObjectOfType <Camera>();
        playerAudio = GetComponent <AudioSource>();
        try
        {
            third_person_character_controller = GetComponent <ThirdPersonCharacter>();
            agent.updateRotation = false; // controlled by animation
        }
        catch (MissingComponentException)
        { //Debug.Log("No ThirdPersonCharacter hence default movements");
        }
    }
示例#48
0
        void Awake()
        {
            maxHealth = Health;

            if (photonView.isMine)
            {
                LocalPlayerInstance = gameObject;
                ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable();
                hash.Add("RobeColor_RGB", new Vector3(RobeColor.r, RobeColor.g, RobeColor.b));
                PhotonNetwork.player.SetCustomProperties(hash);
            }
            else
            {
                ThirdPersonUserControlPun control  = GetComponent <ThirdPersonUserControlPun>();
                ThirdPersonCharacter      movement = GetComponent <ThirdPersonCharacter>();
                control.enabled  = false;
                movement.enabled = false;
            }
            photonView.owner.TagObject = gameObject;
            DontDestroyOnLoad(gameObject);
        }
示例#49
0
 // Use this for initialization
 void Start()
 {
     agent = GetComponent<NavMeshAgent> ();
     character = GetComponent<ThirdPersonCharacter>();
 }
 // Part 4 of practical guide to UMA https://youtu.be/KZpvgiAdD9c
 void Start()
 {
     GenerateUMA();
     characterController = GameObject.FindObjectOfType<ThirdPersonCharacter>();
 }
示例#51
0
    // Use this for initialization
    void Start()
    {
        if (GLOBAL.Player != null)
        {
            // Set this as the current player.
            if (!isProxy)
            {
                if (Multiplayer_ProxyController.Instance != null)
                    Multiplayer_ProxyController.Instance.currentPlayer = this;

                // Retrieve the player's settings.
                username = GLOBAL.Player.username;
                isMale = GLOBAL.Player.progress["isMale"].b;
                index_BodyModel = GLOBAL.Player.progress["index_BodyModel"].i;
                index_HairModel = GLOBAL.Player.progress["index_HairModel"].i;
                index_SkinColor = GLOBAL.Player.progress["index_SkinColor"].i;
                index_HairColor = GLOBAL.Player.progress["index_HairColor"].i;

                Debug.Log(string.Format
                (
                    "Start() - isMale: {0}, index_BodyModel: {1}, index_HairModel: {2}, index_SkinColor: {3}, index_HairColor: {4}",
                    isMale,
                    index_BodyModel,
                    index_HairModel,
                    index_SkinColor,
                    index_HairColor
                ));

                GetComponent<Rigidbody>().useGravity = true;
                GetComponent<Collider>().isTrigger = false;

                // Let the everyone know of the current player entity.
                GLOBAL.player_entity = this;

                // Try to spawn the player on the spawn target.
                if (!String.IsNullOrEmpty(GLOBAL.target_spawn))
                {
                    // If we find an object with the target spawn name, copy its position and rotation.
                    GameObject obj_spawn = GameObject.Find(GLOBAL.target_spawn);
                    if (obj_spawn != null)
                    {
                        transform.position = obj_spawn.transform.position;
                        //transform.rotation = obj_spawn.transform.localRotation;
                    }
                    else
                    {
                        Debug.LogError(String.Format("Could not find spawn target '{0}'.", GLOBAL.target_spawn));
                    }
                }
            }
            else
            {
                // Disable the animation scripts for proxies.
                GetComponent<PlayerInputControl>().enabled = false;

                // Disable the Audio components for proxies.
                if(GetComponent<AudioSource>() != null)
                    GetComponent<AudioSource>().enabled = false;
                if(GetComponent<AudioListener>() != null)
                    GetComponent<AudioListener>().enabled = false;

                // Disable the quick travel script for proxies.
                if (GetComponent<QuickTravel>() != null)
                    GetComponent<QuickTravel>().enabled = false;

                GetComponent<Rigidbody>().useGravity = false;
                GetComponent<Collider>().isTrigger = true;
            }

            _ThirdPersonCharacter = GetComponent<ThirdPersonCharacter>();

            ApplyPlayerModel();

            // _rigidbody = GetComponent<Rigidbody>();
        }
    }
示例#52
0
 // Use this for initialization
 void Awake()
 {
     this.refCharacter = GetComponent<ThirdPersonCharacter>();
 }
示例#53
0
    void Start()
    {
        animator = GetComponent<Animator>();
        thirdPersonCharacter = GetComponent<ThirdPersonCharacter>();
        navMeshAgent = GetComponent<NavMeshAgent>();
        navMeshAgent.updatePosition = false;
        navMeshAgent.updateRotation = false;

        currentIndex = 0;

        ChangeState(new PatrolState());
    }
示例#54
0
    void findNextField(ThirdPersonCharacter profi, int xCoord, int zCoord)
    {
        float backgroundTargetPosAxis;
        Vector3 backgroundTargetPos;
        Transform prof = profi.transform;

        switch (rueckweg[xCoord, zCoord]) {
        case 3:
            //Move right
            backgroundTargetPosAxis = prof.position.z + 5;
            backgroundTargetPos = new Vector3 (prof.position.x, prof.position.y, backgroundTargetPosAxis);
            profi.Move (backgroundTargetPos-prof.position, false, false, backgroundTargetPos-prof.position);
            //fade between current and target position using lerp
            //prof.position = Vector3.Lerp (prof.position, backgroundTargetPos, Time.deltaTime);
            break;
        case 4:
            //Move left
            backgroundTargetPosAxis = prof.position.z - 5;
            backgroundTargetPos = new Vector3 (prof.position.x, prof.position.y, backgroundTargetPosAxis);
            profi.Move (backgroundTargetPos-prof.position, false, false, backgroundTargetPos-prof.position);
            //fade between current and target position using lerp
            //prof.position = Vector3.Lerp (prof.position, backgroundTargetPos, Time.deltaTime);
            break;
        case 2:
            //Move up
            backgroundTargetPosAxis = prof.position.x + 5;
            backgroundTargetPos = new Vector3 (backgroundTargetPosAxis, prof.position.y, prof.position.z);
            profi.Move (backgroundTargetPos-prof.position, false, false, backgroundTargetPos-prof.position);
            //fade between current and target position using lerp
            //prof.position = Vector3.Lerp (prof.position, backgroundTargetPos, Time.deltaTime);
            break;
        case 1:
            //Move down
            backgroundTargetPosAxis = prof.position.x - 5;
            backgroundTargetPos = new Vector3 (backgroundTargetPosAxis, prof.position.y, prof.position.z);
            profi.Move (backgroundTargetPos-prof.position, false, false, backgroundTargetPos-prof.position);
            //fade between current and target position using lerp
            //prof.position = Vector3.Lerp (prof.position, backgroundTargetPos, Time.deltaTime);
            break;
        }
        profi.life.transform.position = prof.position + (new Vector3(0f, 3f, 0f));
    }
示例#55
0
 // Use this for initialization
 void Start()
 {
     animator = GetComponent<Animator>();
     character = GetComponent<ThirdPersonCharacter>();
 }
示例#56
0
 void Start()
 {
     m_AICharacterControl = GetComponent<AICharacterControl>();
     m_character = GetComponent<ThirdPersonCharacter>();
 }
示例#57
0
 void damage(ThirdPersonCharacter per)
 {
     if (lives > 1) {
         lives--;
         toBeRemoved.AddLast (per);
     }else {
         toBeRemoved.AddLast (per);
         gameover = true;
         Debug.Log ("Game Over!");
     }
 }
 private void Start()
 {
     this.cam = Camera.main.transform;
     this.character = base.GetComponent<ThirdPersonCharacter>();
 }
 // Start and Update Methods ************************************************************
 public void Start()
 {
     unityCharacter = GameObject.FindWithTag("Player").GetComponent<ThirdPersonCharacter>();
 }
示例#60
0
 // Use this for initialization
 void Start()
 {
     Rags = GameManager.god.ragsObject;
     boostLimit = boostCounter;
 }