public Vector3 GetMouseCursorTargetLocation() { if (GetComponent <PlayerCharacter>() != null && InputMovement.isDragging) { return(Vector3.positiveInfinity); } if (GetComponent <PlayerCharacter>() != null && !InputMovement.ClickIsOnUi()) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { return(hit.point); } else { return(Vector3.positiveInfinity); } } else if (GetComponent <PlayerCharacter>() != null) { return(Vector3.positiveInfinity); } else if (Vector3.Distance(transform.position, PlayerCharacter.players[0].transform.position) < 20f) { return(PlayerCharacter.players[0].transform.position); } else { return(Vector3.positiveInfinity); } }
void Start() { score=0; inputMovement= GameObject.FindGameObjectWithTag("Player").GetComponent<InputMovement>(); nGUI= GameObject.FindGameObjectWithTag("MainCamera").GetComponent<NGUI>(); lives= 3; }
void LateUpdate() { animationController.Animate(); if (!GetComponent <PlayerCharacter>().isMe || GetComponent <Health>().hp <= 0) { return; } InputMovement.KeyboardCheck(); InputMovement.MouseCheck(); }
void Start() { normalSpeed=2; inputMovement= GameObject.FindGameObjectWithTag("Player").GetComponent<InputMovement>(); carRespawn= GameObject.FindGameObjectWithTag("CarRespawn").GetComponent<CarRespawn>(); lane= new float[5]; for(int i=0; i<5;i++){ lane[i]= carRespawn.lane[i].transform.position.x; } ChangeCarPos(); }
private void Start() { combatInput = InputCombat.Instance; interactionInput = InputInteraction.Instance; movementInput = InputMovement.Instance; audioSource.minDistance = 1; audioSource.maxDistance = 50; audioSource.volume = 1f; audioSource.spatialBlend = 1f; }
void Start() { carRespawn= GameObject.FindGameObjectWithTag("CarRespawn").GetComponent<CarRespawn>(); inputMovement= GameObject.FindGameObjectWithTag("Player").GetComponent<InputMovement>(); collision= GameObject.FindGameObjectWithTag("Player").GetComponent<Collision>(); lane= new float[5]; for(int i=0; i<5;i++){ lane[i]= carRespawn.lane[i].transform.position.x; } ChangeMotorcyclePos(); }
public Player(Vector2 position, int width, int height, int hp, float speed) : base(position, width, height, hp, speed) { playerStates = new PlayerStates(this); movement = new InputMovement(Keys.W, Keys.A, Keys.S, Keys.D, this); attack = new InputAbilities(OnAttack, AttackRequirement); speedMultiplier = 1.5f; // value can be used for heavier/lighter weapons to determine attack interval and energyloss weaponWeight = 0.1f; attackInterval = weaponWeight; energyLoss = maxEnergy * weaponWeight; }
private void Initialize() { //if (!isLocalPlayer) return; if (ProtoClient.localPlayer != GetComponent <NetworkCharacterSyncer>()) { return; } inventory = GameObject.FindGameObjectWithTag("Inventory"); inventoryDetails = GameObject.FindGameObjectWithTag("InventoryDetails"); //spiritScreen = GameObject.FindGameObjectWithTag("SpiritScreen"); //minimap = GameObject.FindGameObjectWithTag("Minimap"); //fpsBar = GameObject.FindGameObjectWithTag("FPSBar"); characterSheet = GameObject.FindGameObjectWithTag("CharacterSheet"); abilityScreen = GameObject.FindGameObjectWithTag("AbilityScreen"); settingsMenu = GameObject.FindGameObjectWithTag("SettingsMenu"); //controlsReference = GameObject.FindGameObjectWithTag("ControlsReference"); //abilityGuide = GameObject.FindGameObjectWithTag("AbilityGuide"); changelog = GameObject.FindGameObjectWithTag("Changelog"); readingPane = GameObject.FindGameObjectWithTag("ReadingPane"); //mouseOverPanel = GameObject.FindGameObjectWithTag("MouseOverPanel"); //if (inventory == null || spiritScreen == null || minimap == null || fpsBar == null || characterSheet == null) return; //inventoryController = inventory.GetComponent<Inventory>(); //GetComponent<PlayerCharacter>().inventory = inventoryController; //spiritScreenController = spiritScreen.GetComponent<SpiritScreen>(); //inventory.SetActive(false); //spiritScreen.SetActive(false); //characterSheet.SetActive(false); //abilityScreen.SetActive(false); //settingsMenu.SetActive(false); //controlsReference.SetActive(false); //abilityGuide.SetActive(false); if (inventory == null || inventoryDetails == null || characterSheet == null || abilityScreen == null || changelog == null || readingPane == null || settingsMenu == null) { return; } changelog.SetActive(false); readingPane.SetActive(false); //mouseOverPanel.SetActive(false); inventoryDetails.SetActive(false); inventory.GetComponent <DuloGames.UI.UIWindow>().Hide(); characterSheet.GetComponent <DuloGames.UI.UIWindow>().Hide(); abilityScreen.GetComponent <DuloGames.UI.UIWindow>().Hide(); settingsMenu.GetComponent <DuloGames.UI.UIWindow>().Hide(); rigidbody = GetComponent <Rigidbody>(); character = GetComponent <Character>(); GetComponent <InputAbilities>().Initialize(this); InputMovement.Initialize(this); }
public virtual void UpdateMovement() { GameObject input = GameObject.Find("Manager"); InputMovement input_movement = (InputMovement)input.GetComponent(typeof(InputMovement)); GameObject CraneObj; GameObject TowerObj; GameObject BoomObj; GameObject BoomHighestPoint; GameObject Lift; CraneObj = input_movement.CraneObj; TowerObj = input_movement.TowerObj; BoomObj = input_movement.BoomObj; BoomHighestPoint = input_movement.BoomHighestPoint; Lift = input_movement.Lift; if (HaltUpdateMovement) { return; } bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow); bool moveLeft = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow); bool moveRight = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow); bool moveBack = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow); bool dpad_move = false; if (OVRInput.Get(OVRInput.Button.DpadUp)) { //moveForward = true; //dpad_move = true; PosX = 1; PosY = 0; PosZ = 0; CraneObj.transform.Rotate(0, 0, 0); CraneObj.transform.position = new Vector3(-PosX * Mathf.Cos(CraneObj.transform.eulerAngles.y * Mathf.PI / 180), PosY, PosX * Mathf.Sin(CraneObj.transform.eulerAngles.y * Mathf.PI / 180)) + CraneObj.transform.position; } if (OVRInput.Get(OVRInput.Button.DpadDown)) { //moveBack = true; //dpad_move = true; PosX = -1; PosY = 0; PosZ = 0; CraneObj.transform.Rotate(0, 0, 0); CraneObj.transform.position = new Vector3(-PosX * Mathf.Cos(CraneObj.transform.eulerAngles.y * Mathf.PI / 180), PosY, PosX * Mathf.Sin(CraneObj.transform.eulerAngles.y * Mathf.PI / 180)) + CraneObj.transform.position; } if (OVRInput.Get(OVRInput.Button.DpadRight)) { PosX = 0; PosY = 0; PosZ = 0; CraneObj.transform.Rotate(0, +1, 0); CraneObj.transform.position = new Vector3(-PosX * Mathf.Cos(CraneObj.transform.eulerAngles.y * Mathf.PI / 180), PosY, PosX * Mathf.Sin(CraneObj.transform.eulerAngles.y * Mathf.PI / 180)) + CraneObj.transform.position; } if (OVRInput.Get(OVRInput.Button.DpadLeft)) { PosX = 0; PosY = 0; PosZ = 0; CraneObj.transform.Rotate(0, -1, 0); CraneObj.transform.position = new Vector3(-PosX * Mathf.Cos(CraneObj.transform.eulerAngles.y * Mathf.PI / 180), PosY, PosX * Mathf.Sin(CraneObj.transform.eulerAngles.y * Mathf.PI / 180)) + CraneObj.transform.position; } if (OVRInput.Get(OVRInput.Button.PrimaryShoulder)) { //MovementObj.transform.localPosition = new Vector3(PosX, PosY, PosZ); TowerObj.transform.Rotate(0, -1, 0); } if (OVRInput.Get(OVRInput.Button.SecondaryShoulder)) { //MovementObj.transform.localPosition = new Vector3(PosX, PosY, PosZ); TowerObj.transform.Rotate(0, 1, 0); } if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)) { BoomObj.transform.Rotate(0, 0, -1); // Mesh mo = MeshObj.GetComponent<MeshFilter>().mesh; // Mesh mo2 = MovementObj. float PosX; float PosY; float PosZ; PosX = BoomHighestPoint.transform.position.x; PosY = Lift.transform.position.y; PosZ = BoomHighestPoint.transform.position.z; Lift.transform.position = new Vector3(PosX, PosY, PosZ); } if (OVRInput.Get(OVRInput.Button.SecondaryIndexTrigger)) { BoomObj.transform.Rotate(0, 0, +1); // Mesh mo = MeshObj.GetComponent<MeshFilter>().mesh; // Mesh mo2 = MovementObj. float PosX; float PosY; float PosZ; PosX = BoomHighestPoint.transform.position.x; PosY = Lift.transform.position.y; PosZ = BoomHighestPoint.transform.position.z; Lift.transform.position = new Vector3(PosX, PosY, PosZ); } if (OVRInput.Get(OVRInput.Button.Four)) { //MovementObj.transform.localPosition = new Vector3(PosX, PosY, PosZ); //MovementObj.transform.Rotate(RotX, RotY, RotZ); Lift.transform.position = new Vector3(0, +1, 0) + Lift.transform.position; } if (OVRInput.Get(OVRInput.Button.Three)) { //MovementObj.transform.localPosition = new Vector3(PosX, PosY, PosZ); Lift.transform.Rotate(0, -1, 0); } if (OVRInput.Get(OVRInput.Button.One)) { //MovementObj.transform.localPosition = new Vector3(PosX, PosY, PosZ); //MovementObj.transform.Rotate(RotX, RotY, RotZ); Lift.transform.position = new Vector3(0, -1, 0) + Lift.transform.position; } if (OVRInput.Get(OVRInput.Button.Two)) { //MovementObj.transform.localPosition = new Vector3(PosX, PosY, PosZ); Lift.transform.Rotate(0, +1, 0); } //Vector3 euler = cam1.transform.rotation; if (OVRInput.Get(OVRInput.Button.Start)) { if (Vector3.Distance(cam1.transform.localPosition, InitLocalpos) < 2.0f) { Debug.Log(Vector3.Distance(cam1.transform.localPosition, InitLocalpos)); cam1.transform.position = new Vector3(100f, 1.1f, 100f); //view= new Vector3(-30.67139f,104.669f,-7.704061f); //euler= new Vector3(90.0f, -132.1579f, 0.0f); cam1.SetActive(true); } else { } if (Vector3.Distance(cam1.transform.position, new Vector3(100f, 1.1f, 100f)) < 10.0f) { Debug.Log(Vector3.Distance(cam1.transform.position, new Vector3(100f, 1.1f, 100f))); cam1.transform.position = InitLocalpos; //view= new Vector3(-30.67139f,104.669f,-7.704061f); //euler= new Vector3(90.0f, -132.1579f, 0.0f); cam1.SetActive(true); } } if (OVRInput.Get(OVRInput.Button.Back)) { cam1.transform.localPosition = InitLocalpos; //view= new Vector3(-30.67139f,104.669f,-7.704061f); //euler= new Vector3(90.0f, -132.1579f, 0.0f); cam1.SetActive(true); } MoveScale = 1.0f; if ((moveForward && moveLeft) || (moveForward && moveRight) || (moveBack && moveLeft) || (moveBack && moveRight)) { MoveScale = 0.70710678f; } // No positional movement if we are in the air if (!Controller.isGrounded) { MoveScale = 0.0f; } MoveScale *= SimulationRate * Time.deltaTime; // Compute this for key movement float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; // Run! if (dpad_move || Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { moveInfluence *= 2.0f; } Quaternion ort = transform.rotation; Vector3 ortEuler = ort.eulerAngles; ortEuler.z = ortEuler.x = 0f; ort = Quaternion.Euler(ortEuler); if (moveForward) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward); } if (moveBack) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back); } if (moveLeft) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left); } if (moveRight) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right); } //Vector3 euler = transform.rotation.eulerAngles; bool curHatLeft = OVRInput.Get(OVRInput.Button.PrimaryShoulder); if (curHatLeft && !prevHatLeft) { //euler.y -= RotationRatchet; } prevHatLeft = curHatLeft; bool curHatRight = OVRInput.Get(OVRInput.Button.SecondaryShoulder); if (curHatRight && !prevHatRight) { //euler.y += RotationRatchet; prevHatRight = curHatRight; } //Use keys to ratchet rotation //if (Input.GetKeyDown(KeyCode.Q)) // euler.y -= RotationRatchet; //if (Input.GetKeyDown(KeyCode.E)) // euler.y += RotationRatchet; float rotateInfluence = SimulationRate * Time.deltaTime * RotationAmount * RotationScaleMultiplier; #if !UNITY_ANDROID || UNITY_EDITOR if (!SkipMouseRotation) //euler.y += Input.GetAxis("Mouse X") * rotateInfluence * 3.25f; #endif moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; #if !UNITY_ANDROID // LeftTrigger not avail on Android game pad moveInfluence *= 1.0f + OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger); #endif Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick); if (primaryAxis.y > 0.0f) { MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.z * moveInfluence * Vector3.forward); } if (primaryAxis.y < 0.0f) { MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back); } if (primaryAxis.x < 0.0f) { MoveThrottle += ort * (Mathf.Abs(primaryAxis.x) * transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left); } if (primaryAxis.x > 0.0f) { MoveThrottle += ort * (primaryAxis.x * transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right); } Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick); //euler.y += secondaryAxis.x * rotateInfluence; //transform.rotation = Quaternion.Euler(euler); }
void Start() { inputMovement= GameObject.FindGameObjectWithTag("Player").GetComponent<InputMovement>(); }
private void Awake() { inputPlayer = new InputMovement(); controller = GetComponent <CharacterController>(); }
private void Awake() { inputPlayer = new InputMovement(); cinemachine = GetComponent <CinemachineFreeLook>(); }