// Using mouse private void UpdateMove() { #if false _mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, CameraDif); _lookPos = Camera.main.ScreenToWorldPoint(_mousePos); _lookPos.y = _graphics.position.y; _graphics.LookAt(_lookPos); #else RaycastHit hitInfo; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); CharacterMotorC motor = GetComponent <CharacterMotorC>(); if (Physics.Raycast(ray, out hitInfo, 100, LayerMask.GetMask("Terrain"))) { if (Input.GetMouseButton(0)) { RunToPos(hitInfo.point); _graphics.GetComponent <Animation>().CrossFade("run"); Vector3 movDir = _lookPos - _graphics.transform.position; if (movDir.magnitude > motor.movement.maxForwardSpeed) { movDir = movDir.normalized * motor.movement.maxForwardSpeed; } motor.inputMoveDirection = movDir; } else { _lookPos = hitInfo.point; _lookPos.y = _graphics.position.y; _graphics.LookAt(_lookPos); motor.inputMoveDirection = Vector3.zero; _graphics.GetComponent <Animation>().CrossFade("idle"); } } #endif }
void Start() { motor = GetComponent <CharacterMotorC>(); useMecanim = GetComponent <AttackTriggerC>().useMecanim; mainModel = GetComponent <AttackTriggerC>().mainModel; if (!mainModel) { mainModel = this.gameObject; } mainCam = GetComponent <AttackTriggerC>().Maincam.gameObject; if (!useMecanim) { //If using Legacy Animation mainModel.GetComponent <Animation>()[swimForward.name].speed = animationSpeed; mainModel.GetComponent <Animation>()[swimRight.name].speed = animationSpeed; mainModel.GetComponent <Animation>()[swimLeft.name].speed = animationSpeed; mainModel.GetComponent <Animation>()[swimBack.name].speed = animationSpeed; } else { //If using Mecanim Animation animator = GetComponent <PlayerMecanimAnimationC>().animator; moveHorizontalState = GetComponent <PlayerMecanimAnimationC>().moveHorizontalState; moveVerticalState = GetComponent <PlayerMecanimAnimationC>().moveVerticalState; jumpState = GetComponent <PlayerMecanimAnimationC>().jumpState; } }
void Awake() { rigid = gameObject.GetComponent <Rigidbody> (); escapeDestination = GameObject.Find("WallR"); BlueFlashlight = GameObject.Find("BlueFlashlight"); NightVision = GameObject.Find("NightVision"); main = GameObject.Find("First Person Controller"); mother = GameObject.Find("Mother"); BehindPlayer = GameObject.Find("BehindPlayer"); leftOfPlayer = GameObject.Find("LeftPlayer"); rightOfPlayer = GameObject.Find("RightPlayer"); cam = GameObject.Find("Main Camera"); seek = false; flash = true; start = true; wait = 3; readyOrNot = 11; startingTalk = 2f; //15 endingSequence = 2; radius = 8; rightPoint = 1000; leftPoint = 1000; nav = GetComponent <NavMeshAgent>(); turnUp = GetComponent <NavMeshAgent>(); collide = GetComponent <SphereCollider> (); mouseLook = (MouseLook)GameObject.Find("Main Camera").GetComponent("MouseLook"); playerLook = (MouseLook)GameObject.Find("First Person Controller").GetComponent("MouseLook"); motor = GameObject.Find("First Person Controller").GetComponent <CharacterMotorC>(); spectrum = GameObject.Find("First Person Controller").GetComponent <SpectrumController> (); playerController = GameObject.Find("First Person Controller").GetComponent <PlayerController>(); echoSpherez = GameObject.Find("First Person Controller").GetComponent <EchoSpherez>(); }
// 此函数是摇杆移动中所要处理的事 void OnJoystickMove(MovingJoystick move) { // 在这里的名字new joystick 就是上面所说的很重要的名字,在上面图片中joystickName的你修改了什么名字,这里就要写你修改的好的名字(不然脚本不起作用)。 if (move.joystickName != "New joystick") { return; } float PositionX = move.joystickAxis.x; // 获取摇杆偏移摇杆中心的x坐标 float PositionY = move.joystickAxis.y; // 获取摇杆偏移摇杆中心的y坐标 CharacterMotorC motor = GetComponent <CharacterMotorC>(); if (PositionY != 0 || PositionX != 0) { // 设置控制角色或物体方块的朝向(当前坐标+摇杆偏移量) _lookPos = new Vector3(_graphics.transform.position.x + PositionX, _graphics.transform.position.y, _graphics.transform.position.z + PositionY); _graphics.LookAt(_lookPos); // 移动角色或物体的位置(按其所朝向的位置移动) //_graphics.transform.Translate(Vector3.forward * Time.deltaTime * 25); Vector3 movDir = (_lookPos - _graphics.transform.position) * motor.movement.maxForwardSpeed; _graphics.GetComponent <Animation>().CrossFade("run"); motor.inputMoveDirection = movDir; } else { _graphics.GetComponent <Animation>().CrossFade("idle"); motor.inputMoveDirection = Vector3.zero; } }
// Use this for initialization void Awake() { motor = GetComponent <CharacterMotorC>(); if (!joyStick) { joyStick = GameObject.FindWithTag("JoyStick"); } }
// Use this for initialization void Start() { motor = GetComponent <CharacterMotorC>(); controller = GetComponent <CharacterController>(); stamina = maxStamina; if (!mainModel) { mainModel = GetComponent <StatusC>().mainModel; } useMecanim = GetComponent <AttackTriggerC>().useMecanim; }
// Use this for initialization void Start() { gloves = GameObject.Find("Gloves"); Player = GameObject.Find("First Person Controller"); deathSequence = 3; inventory = GameObject.Find("First Person Controller").GetComponent <Inventory>(); playerMovement = GameObject.Find("First Person Controller").GetComponent <CharacterMotorC> (); nav = GetComponent <NavMeshAgent> (); nav.speed = 0; StartCoroutine(JumpForward()); }
private void RunToPos(Vector3 pos) { _lookPos = pos; _lookPos.y = _graphics.position.y; _graphics.LookAt(_lookPos); _graphics.GetComponent <Animation>().CrossFade("run"); Vector3 movDir = _lookPos - _graphics.transform.position; CharacterMotorC motor = GetComponent <CharacterMotorC>(); if (movDir.magnitude > motor.movement.maxForwardSpeed) { movDir = movDir.normalized * motor.movement.maxForwardSpeed; } motor.inputMoveDirection = movDir; }
void Start() { DontDestroyOnLoad(transform.gameObject); if (!mainModel) { mainModel = this.gameObject; } if (!mecanimAnimator && useMecanim) { mecanimAnimator = mainModel.GetComponent <Animator>(); } motor = GetComponent <CharacterMotorC>(); motor.movement.maxForwardSpeed = runSpeed; motor.movement.maxSidewaysSpeed = runSpeed; }
void Start() { oldMan = GameObject.Find("OldMan"); hG = GameObject.Find("HospitalGirl"); eyesHere = GameObject.Find("EyesHere"); cam = GameObject.Find("Main Camera"); activationSwitch = GameObject.Find("Activation Switch"); tr = transform; enemyDamage = GameObject.Find("HospitalGirl").GetComponent <HospitalGirl> (); wander = GameObject.Find("OldMan").GetComponent <Wander> (); inventory = GetComponent <Inventory> (); environment = GameObject.Find("Environment").GetComponent <Environmental>(); collect = GameObject.Find("First Person Controller").GetComponent <CollectItem> (); chMotor = GetComponent <CharacterMotorC>(); ch = GetComponent <CharacterController>(); dist = ch.height / 2; // calculate distance to ground }
void Start() { motor = GetComponent<CharacterMotorC>(); useMecanim = GetComponent<AttackTriggerC>().useMecanim; mainModel = GetComponent<AttackTriggerC>().mainModel; if(!mainModel){ mainModel = this.gameObject; } mainCam = GetComponent<AttackTriggerC>().Maincam.gameObject; if(!useMecanim){ //If using Legacy Animation mainModel.GetComponent<Animation>()[swimForward.name].speed = animationSpeed; mainModel.GetComponent<Animation>()[swimRight.name].speed = animationSpeed; mainModel.GetComponent<Animation>()[swimLeft.name].speed = animationSpeed; mainModel.GetComponent<Animation>()[swimBack.name].speed = animationSpeed; }else{ //If using Mecanim Animation animator = GetComponent<PlayerMecanimAnimationC>().animator; moveHorizontalState = GetComponent<PlayerMecanimAnimationC>().moveHorizontalState; moveVerticalState = GetComponent<PlayerMecanimAnimationC>().moveVerticalState; jumpState = GetComponent<PlayerMecanimAnimationC>().jumpState; } }
void Awake() { if (!mainModel) { mainModel = this.gameObject; } mStatusC = GetComponent <StatusC>(); //Assign This mainModel to Status Script mStatusC.mainModel = mainModel; mStatusC.useMecanim = useMecanim; //Set tag to Player. gameObject.tag = "Player"; controller = GetComponent <CharacterController>(); cmc = GetComponent <CharacterMotorC>(); if (!useMecanim) { mAnim = mainModel.GetComponent <Animation>(); } else { if (!mAnimator) { mAnimator = mainModel.GetComponent <Animator>(); } } GameObject[] cam = GameObject.FindGameObjectsWithTag("MainCamera"); foreach (GameObject cam2 in cam) { if (cam2) { Destroy(cam2.gameObject); } } GameObject newCam = GameObject.FindWithTag("MainCamera"); newCam = Instantiate(MaincamPrefab, transform.position, transform.rotation) as GameObject; Maincam = newCam.transform; m_RPGCammer = Maincam.GetComponent <ARPGcameraC>(); //m_RPGCammer.distance = 6.0f; //m_RPGCammer.target = this.transform; // Set Target to ARPG Camera if (!cameraZoomPoint || aimingType == AimType.Normal) { //cameraZoomPoint = this.transform; m_RPGCammer.target = this.transform; } else { m_RPGCammer.target = cameraZoomPoint; } m_RPGCammer.targetBody = this.transform; str = mStatusC.addAtk; matk = mStatusC.addMatk; //Set All Attack Animation'sLayer to 15 int animationSize = attackCombo.Length; int a = 0; if (animationSize > 0 && !useMecanim) { while (a < animationSize && attackCombo[a]) { mAnim[attackCombo[a].name].layer = 15; a++; } } //-------------------------------- //Spawn new Attack Point if you didn't assign it. if (!attackPoint) { if (!attackPointPrefab) { print("Please assign Attack Point"); freeze = true; return; } GameObject newAtkPoint = Instantiate(attackPointPrefab, transform.position, transform.rotation) as GameObject; newAtkPoint.transform.parent = this.transform; attackPoint = newAtkPoint.transform; } if (!useMecanim) { hurt = GetComponent <PlayerAnimationC>().hurt; } if (aimingType == AimType.Raycast) {//Auto Lock On for Raycast Mode m_RPGCammer.lockOn = true; } GameObject minimap = GameObject.FindWithTag("Minimap"); if (minimap) { GameObject mapcam = minimap.GetComponent <MinimapOnOffC>().minimapCam; mapcam.GetComponent <MinimapCameraC>().target = this.transform; } followState = AIState.Idle; if (!useMecanim) { //If using Legacy Animation mAnim = mainModel.GetComponent <Animation>(); mAnim.Play("idle"); // mAnim[hurtAnimation.name].layer = 10; } else { //If using Mecanim Animation if (!mAnimator) { mAnimator = mainModel.GetComponent <Animator>(); } } mAudio = GetComponent <AudioSource>(); }
// Use this for initialization void Awake() { cm = GameObject.Find("Player").GetComponent <CharacterMotorC> (); }
// Use this for initialization void Awake() { motor = GetComponent<CharacterMotorC>(); stamina = maxStamina; }
// Use this for initialization void Awake() { cmotor = GetComponent<CharacterMotorC>(); }
// Use this for initialization public void Awake () { motor = player.GetComponent<CharacterMotorC>(); if (useHMD && cameraController == null) Debug.LogWarning ("useHMD turned on without camera rig"); }
void GetCharacterMotorCScript() { characterMotorCScript = FindObjectOfType <CharacterMotorC>(); }
// Use this for initialization void Awake() { cmotor = GetComponent <CharacterMotorC>(); }
// Use this for initialization void Awake() { motor = GetComponent <CharacterMotorC>(); stamina = maxStamina; }