//transtions in or out of specified prisoner private float transitionP(Prisoner curPrisoner, bool enter) { float waitTime = 0; if (enter) { //enable third person camera rig and set on target prisonerCamera.gameObject.SetActive(true); prisonerCamera.gameObject.transform.position = curPrisoner.transform.position; //make our camera be set so that it's always looking right behind the player prisonerCamera.gameObject.transform.rotation = Quaternion.LookRotation(curPrisoner.gameObject.transform.forward); prisonerCamera.LookAngle = prisonerCamera.gameObject.transform.eulerAngles.y; //set our current prisoners camera pivot positioning Vector3 pivotPosition = prisonerCamera.gameObject.transform.GetChild(0).localPosition; pivotPosition.y = curPrisoner.camPivVert; pivotPosition.x = curPrisoner.camPivHor; //set zoom and pivot prisonerCamera.gameObject.transform.GetChild(0).localPosition = pivotPosition; prisonerCamera.gameObject.transform.GetChild(0).GetChild(0).localPosition = new Vector3(0, 0, 0); //set our target and enable our animation prisonerCamera.SetTarget(curPrisoner.gameObject.transform); waitTime = curPrisoner.bodyTransition(true); currentlyPossessing = curPrisoner; } else { curPrisoner.stopControlling(); waitTime = curPrisoner.bodyTransition(false); currentlyPossessing = null; } return(waitTime); }
IEnumerator ObserverModeCoroutine() { int currentObserverID; for (currentObserverID = 0; currentObserverID < survivors.Length; currentObserverID++) { if (!survivors[currentObserverID].GetComponent <SurvivorStatus>().IsDead()) { FreeLookCam.SetTarget(survivors[currentObserverID].transform); break; } } Text ObservingTargetText = UICanvas.transform.Find("ObserverModePanel/ObserverModeBarImage/ObservingTargetText").GetComponent <Text>(); ObservingTargetText.text = survivors[currentObserverID].GetComponent <SurvivorStatus>().PlayerName + " 관전 중"; UICanvas.transform.Find("ObserverModePanel").gameObject.SetActive(true); while (true) { if (Input.GetMouseButtonUp(0)) { for (currentObserverID = currentObserverID + 1; ; currentObserverID++) { currentObserverID %= survivors.Length; if (!survivors[currentObserverID].GetComponent <SurvivorStatus>().IsDead()) { FreeLookCam.SetTarget(survivors[currentObserverID].transform); ObservingTargetText.text = survivors[currentObserverID].GetComponent <SurvivorStatus>().PlayerName + " 관전 중"; break; } } } if (isGameOver) { break; } yield return(null); } }
// Update is called once per frame private void Update() { if (canTransform) { // Allow player to change forms using numeric input 1 and 2. if (Input.GetKeyDown(KeyCode.Alpha1)) { currentForm = ballForm; // Change game objects. activateBobForm(false); activateBallForm(true); // Have camera focus on the game object. camScript.SetTarget(ball.transform); // Set the current transform as the transform of the game object. ball.transform.SetPositionAndRotation(location, new Quaternion(0, 0, 0, 0)); bob.transform.Rotate(new Vector3(0, camObject.transform.rotation.eulerAngles.y + 180, 0)); // Apply the current velocity to the game object. //ball.GetComponent<Rigidbody> ().AddForce (bob.GetComponent<Rigidbody> ().velocity, ForceMode.VelocityChange); } else if (Input.GetKeyDown(KeyCode.Alpha2)) { currentForm = bobForm; activateBallForm(false); activateBobForm(true); camScript.SetTarget(bob.transform); // Set the position, and rotation so the car faces in the direction of the camera. bob.transform.SetPositionAndRotation(location, new Quaternion(0, 0, 0, 0)); bob.transform.Rotate(new Vector3(0, camObject.transform.rotation.eulerAngles.y, 0)); //bob.GetComponent<Rigidbody> ().AddForce (ball.GetComponent<Rigidbody> ().velocity, ForceMode.VelocityChange); } } if (currentForm == ballForm) { location = ball.transform.position; } else if (currentForm == bobForm) { location = bob.transform.position; } }
public void CreateCameraToPlayer() { var cameraInstantiate = Instantiate(Cameras, transform.position, Quaternion.identity); FreeLookCam freeLookCam = cameraInstantiate.transform.Find("FreeLookCameraRig").GetComponent <FreeLookCam>(); GetComponent <PlayerController>().SetCurrentCameraTranform(freeLookCam.GetComponent <Transform>()); freeLookCam.SetTarget(this.gameObject.transform); Transform ThirdCameraObj = GameObject.FindWithTag("ThirdCamera").GetComponent <Transform>(); GameObject objectgoot; objectgoot = ThirdCameraObj.gameObject; CameraControllerPlayer.SetThirdCamera(objectgoot); }
public void Awake() { Camera = GameObject.FindObjectOfType <FreeLookCam> (); // in case we started this demo with the wrong scene being active, simply load the menu scene if (!PhotonNetwork.connected) { SceneManager.LoadScene(WorkerMenu.SceneNameMenu); return; } Vector3 position = new Vector3(1000, 50, 300); // we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate GameObject newPlayerObject = PhotonNetwork.Instantiate("UMARPG", position, Quaternion.identity, 0); Camera.SetTarget(newPlayerObject.transform); }
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>(); }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } if (_FreeCam.Target != transform) { _FreeCam.SetTarget(transform); } if (_anim.GetCurrentAnimatorStateInfo(0).IsName("Locomotion")) { float vertical = Input.GetAxis("Vertical"); if (vertical > 0) { _anim.SetFloat("Velocidad", vertical); transform.eulerAngles = new Vector3(transform.eulerAngles.x, _Cam.eulerAngles.y, transform.eulerAngles.z); _rb.velocity = transform.forward * Velocity * vertical * (Input.GetKey(KeyCode.LeftShift) ? 2 : 1); } if (Input.GetMouseButtonDown(0)) { _anim.SetTrigger("Ataque"); RaycastHit ht; Ray r = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(r, out ht, 999f)) { if (ht.collider.GetComponent <Stats>()) { CmdChangeHealth(10, ht.collider.gameObject); } } } } }
public static void SetCameraTarget(BoltEntity Entity) { FreeLookCam lookCam = GameObject.Find("FreeLookCameraRig").GetComponent <FreeLookCam>(); lookCam.SetTarget(Entity.gameObject.transform); }
public void CreateRole(int roleId) { // 添加角色相关数据 //mRoleObject = ObjectManager.mRole; Vector3 pos = Vector3.zero; if (mRoleObject != null) { pos = mRoleObject.mPosition; ObjectManager.DestroyObject(mRoleObject); } if (mRoleObject == null) { mRoleObject = new CRoleObject(); } ObjectManager.mRole = mRoleObject; ObjectManager.mRole.mObjId = roleId; // 加载主角资源 mRoleGo = ResourceManager.Instance.GetRolePrefab(roleId + "_Tpose"); if (mRoleGo == null) { return; } mRoleGo.name = roleId.ToString(); if (pos.Equals(Vector3.zero)) { mRoleObject.mPosition = new Vector3(-95f, 4.78f, -84f); } mRoleGo.transform.localPosition = mRoleObject.mPosition; mRoleGo.transform.localScale = new Vector3(1.2f, 1.2f, 1.2f); mRoleObject.mObjModel = roleId; mRoleObject.mGameObject = mRoleGo; mRoleObject.mTransform = mRoleGo.transform; // 创建主相机 //mMainCamera = GameObject.Find("Main Camera"); //if (mMainCamera == null) //{ // mMainCamera = new GameObject("Main Camera"); // Camera camera = mMainCamera.AddComponent<Camera>(); //} // 相机跟随 //mCameraMove = mMainCamera.GetComponent<CameraMove>(); //if (mCameraMove == null) //{ // mCameraMove = mMainCamera.AddComponent<CameraMove>(); //} //mCameraMove.SetRoleGameObject(mRoleGo.transform.Find("Bip01").gameObject); _mFreeCam = GameObject.Find("FreeLookCameraRig").GetComponent <FreeLookCam>(); _mFreeCam.SetTarget(mRoleObject.mTransform); // 添加角色移动控制器 PlayerCtrlManager mPlayerCtrlManager = mRoleGo.GetComponent <PlayerCtrlManager>(); if (mPlayerCtrlManager == null) { mPlayerCtrlManager = mRoleGo.AddComponent <PlayerCtrlManager>(); } if (mRoleObject.mGameObject.GetComponent <AudioListener>() == null) { mRoleObject.mGameObject.AddComponent <AudioListener>(); } UIManager.Instance.OpenUI("UHUDUI"); UIManager.Instance.mHUDUIPanel = GameObject.Find("UHUDUI").GetComponent <UHUDUI>(); // 添加角色逻辑组件 mRoleObject.AddComponent <FindingPathComponent>(); mRoleObject.AddComponent <AnimatorComponent>(); mRoleObject.AddComponent <SkillComponent>(); mRoleObject.AddComponent <ViewComponent>(); mRoleObject.AddComponent <MoveComponent>(); mRoleObject.AddComponent <RestoreComponent>(); mRoleObject.AddComponent <InjuredComponent>(); mRoleObject.AddComponent <EffectComponent>(); }
public void SetCameraTarget(GameObject target) { cam.SetTarget(target.transform); }
void Start() { mCamera = GameObject.Find("FreeLookCameraRig").GetComponent <FreeLookCam>(); mCamera.SetTarget(transform); }