// Update is called once per frame void Update() { #if CROSS_PLATFORM_INPUT if (CrossPlatformInput.GetButtonDown("Jump")) { playerJump(); } float h = CrossPlatformInput.GetAxis("Horizontal"); #else if (Input.GetButtonDown("Jump")) { playerJump(); } float h = Input.GetAxis("Horizontal"); #endif charged = Input.GetKey(KeyCode.LeftControl); if (Input.GetButtonDown("Fire1") && inventory.menuItems.Count != 0 && behaviour.currentItem != 0) { behaviour.useItem(); } if (Input.GetAxis("Mouse ScrollWheel") != 0 && inventory.menuItems.Count != 0) { behaviour.switchItem((int)Mathf.Sign(Input.GetAxis("Mouse ScrollWheel"))); } playerMove(h); }
// Fixed update is called in sync with physics void FixedUpdate() { // read inputs bool crouch = Input.GetKey(KeyCode.C); bool jump = CrossPlatformInput.GetButton("Jump"); float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); // calculate move direction to pass to character Vector3 camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; Vector3 move = v * camForward + h * cam.right; #if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8) // On standalone builds, walk/run speed is modified by a key press. bool walkToggle = Input.GetKey(KeyCode.LeftShift); // We select appropriate speed based on whether we're walking by default, and whether the walk/run toggle button is pressed: float walkMultiplier = (walkByDefault ? walkToggle ? 1 : 0.5f : walkToggle ? 0.5f : 1); move *= walkMultiplier; #endif // On mobile, it's controlled in analogue fashion by the v input value, and therefore needs no special handling. // calculate the head look target position lookPos = lookInCameraDirection && cam != null ? transform.position + cam.forward * 100 : transform.position + transform.forward * 100; // pass all parameters to the character control script character.Move(move, crouch, jump, lookPos); }
void FixedUpdate() { // Read the inputs. bool shooting = false; #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); if (CrossPlatformInput.GetButton("FireLeft")) { shooting = true; shootDirection = Direction.LEFT; } else if (CrossPlatformInput.GetButton("FireRight")) { shooting = true; shootDirection = Direction.RIGHT; } #else float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif // Pass all parameters to the character control script. character.Move(h, v); if (shooting) { character.shoot(shootDirection); } }
// Token: 0x06005264 RID: 21092 RVA: 0x001C4838 File Offset: 0x001C2C38 private void UpdateInput() { if (VRCInputManager.comfortTurning) { return; } base.transform.localRotation = this.originalRotation; if (this.relative) { float num = CrossPlatformInput.GetAxis("Mouse X"); float num2 = CrossPlatformInput.GetAxis("Mouse Y"); num += this.inLookHorizontal.axis * this.controllerRotationSpeed; num2 -= this.inLookVertical.axis * this.controllerRotationSpeed; if (this.targetAngles.y > 180f) { this.targetAngles.y = this.targetAngles.y - 360f; this.followAngles.y = this.followAngles.y - 360f; } if (this.targetAngles.x > 180f) { this.targetAngles.x = this.targetAngles.x - 360f; this.followAngles.x = this.followAngles.x - 360f; } if (this.targetAngles.y < -180f) { this.targetAngles.y = this.targetAngles.y + 360f; this.followAngles.y = this.followAngles.y + 360f; } if (this.targetAngles.x < -180f) { this.targetAngles.x = this.targetAngles.x + 360f; this.followAngles.x = this.followAngles.x + 360f; } this.targetAngles.y = this.targetAngles.y + num * this.rotationSpeed; this.targetAngles.x = this.targetAngles.x + num2 * this.rotationSpeed; this.targetAngles.y = Mathf.Clamp(this.targetAngles.y, -this.rotationRange.y * 0.5f, this.rotationRange.y * 0.5f); this.targetAngles.x = Mathf.Clamp(this.targetAngles.x, this.rotationRange.x, this.rotationRange.z); } else { float num = Input.mousePosition.x; float num2 = Input.mousePosition.y; this.targetAngles.y = Mathf.Lerp(-this.rotationRange.y * 0.5f, this.rotationRange.y * 0.5f, num / (float)Screen.width); this.targetAngles.x = Mathf.Lerp(this.rotationRange.x, this.rotationRange.z, num2 / (float)Screen.height); } this.followAngles = Vector3.SmoothDamp(this.followAngles, this.targetAngles, ref this.followVelocity, this.dampingTime); base.transform.localRotation = this.originalRotation * Quaternion.Euler(-this.followAngles.x, this.followAngles.y, 0f); float num3 = Mathf.Clamp(this.followAngles.x - this.originalEulers.x, -60f, 60f); Vector3 localPosition = this.originalPosition; if (num3 < 0f) { localPosition.y += this.neckLookDownDist * num3 / 60f; } if (num3 > 0f) { localPosition.y -= this.neckLookUpDist * num3 / 60f; } base.transform.localPosition = localPosition; }
void Update() { // Get the axis and jump input. #if CROSS_PLATFORM_INPUT jump = CrossPlatformInput.GetButton("Jump"); float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); #else jump = Input.GetButton("Jump"); float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif // calculate move direction if (cam != null) { // calculate camera relative direction to move: camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; move = (v * camForward + h * cam.right).normalized; } else { // we use world-relative directions in the case of no main camera move = (v * Vector3.forward + h * Vector3.right).normalized; } }
void FixedUpdate() { bool jumpActive = (Input.GetButtonDown("Jump") && joueur == 1) || (Input.GetButtonDown("Jump2") && joueur == 2); bool nitro = (Input.GetKey(KeyCode.LeftShift) && joueur == 1) || (Input.GetKey(KeyCode.RightShift) && joueur == 2); if (nitro) { nitroBar.value -= nitroConsumption; } // pass the input to the car! #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis(horizontal); float v = CrossPlatformInput.GetAxis(vertical); bool f = (Input.GetButtonDown("Fire1") && joueur == 1) || (Input.GetButtonDown("Fire2") && joueur == 2); #else float h = Input.GetAxis(horizontal); float v = Input.GetAxis(vertical); bool f = Input.GetButton("Fire1"); #endif car.Move(h, v, jumpActive, nitro); if (Time.time > nextFire && f) { car.Shoot(f); shootCount++; //Debug.Log("Shoot Count : " + shootCount.ToString()); nextFire = Time.time + fireRate; f = false; } }
void FixedUpdate() { //if (networkView.isMine) // { // Read input for the pitch, yaw, roll and throttle of the aeroplane. //#if CROSS_PLATFORM_INPUT float roll = CrossPlatformInput.GetAxis("ROLL"); float pitch = CrossPlatformInput.GetAxis("PITCH"); float yaw = CrossPlatformInput.GetAxis("YAW"); bool airBrakes = CrossPlatformInput.GetButton("THROTTLE"); /*#else * float roll = Input.GetAxis("Horizontal"); * float pitch = Input.GetAxis("Vertical"); * bool airBrakes = Input.GetButton("Fire1"); * //#endif */ // auto throttle up, or down if braking. float throttle = airBrakes ? -1 : 1; AdjustInputForMobileControls(ref roll, ref pitch, ref throttle); // Pass the input to the aeroplane aeroplane.Move(roll, pitch, yaw, throttle, airBrakes); //} }
void FixedUpdate() { // pass the input to the car! #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis(horizontal); float v = CrossPlatformInput.GetAxis(vertical); q = nitro = Input.GetKey(KeyCode.Q); e = nitro = Input.GetKey(KeyCode.E); if (Input.GetKeyDown("f")) { car.GetComponent <CarStatus>().LaunchPowerUp(); } nitro = Input.GetKey(KeyCode.LeftShift); car.GetComponent <CarStatus>().ConsumeNitro(nitro); jump = Input.GetKey(KeyCode.Space); car.GetComponent <CarStatus>().Jump(jump); #else float h = Input.GetAxis(horizontal); float v = Input.GetAxis(vertical); #endif car.Move(h, v, q, e); }
// Fixed update is called in sync with physics void FixedUpdate() { // read inputs bool crouch = Input.GetKey(KeyCode.C); #if CROSS_PLATFORM_INPUT bool jump = CrossPlatformInput.GetButton("Jump"); float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); #else bool jump = Input.GetButton("Jump"); float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif // calculate move direction to pass to character if (cam != null && (lastH != h || lastV != v)) { // calculate camera relative direction to move: camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; move = v * camForward + h * cam.right; } else if (cam == null) { // we use world-relative directions in the case of no main camera move = v * Vector3.forward + h * Vector3.right; } else { move.Normalize(); } lastH = h; lastV = v; if (move.magnitude > 1) { move.Normalize(); } #if !MOBILE_INPUT // On non-mobile builds, walk/run speed is modified by a key press. bool walkToggle = Input.GetKey(KeyCode.LeftShift); // We select appropriate speed based on whether we're walking by default, and whether the walk/run toggle button is pressed: float walkMultiplier = (walkByDefault ? walkToggle ? 1 : 0.5f : walkToggle ? 0.5f : 1); move *= walkMultiplier; #endif // On mobile, walk/run speed is controlled in analogue fashion by the v input value, and therefore needs no special handling. // *hence no code here!* // calculate the head look target position lookPos = (lookInCameraDirection && cam != null) ? transform.position + cam.forward * 100 : transform.position + transform.forward * 100; // pass all parameters to the character control script character.Move(move, crouch, jump, lookPos); }
private void FixedUpdate() { bool key = Input.GetKey(KeyCode.LeftControl); float axis = CrossPlatformInput.GetAxis("Horizontal"); this.character.Move(axis, key, this.jump); this.jump = false; }
void FixedUpdate() { // pass the input to the car! float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); car.Move(h, v); }
private void FixedUpdate() { float axis = CrossPlatformInput.GetAxis("Mouse X"); float axis2 = CrossPlatformInput.GetAxis("Mouse Y"); float axis3 = CrossPlatformInput.GetAxis("Horizontal"); float axis4 = CrossPlatformInput.GetAxis("Vertical"); this.AdjustInputForMobileControls(ref axis, ref axis2, ref axis4); bool button = CrossPlatformInput.GetButton("Fire1"); this.aeroplane.Move(axis, axis2, axis3, axis4, button); }
void FixedUpdate() { // pass the input to the car! #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); #else float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif car.Move(h, v); }
void FixedUpdate() { // Read the inputs. bool crouch = Input.GetKey(KeyCode.LeftControl); float h = CrossPlatformInput.GetAxis("Horizontal"); // Pass all parameters to the character control script. character.Move(h, crouch, jump); // Reset the jump input once it has been used. jump = false; }
void FixedUpdate() { _robotInput.crouch = Input.GetKey(KeyCode.LeftControl); #if CROSS_PLATFORM_INPUT _robotInput.move = CrossPlatformInput.GetAxis("Horizontal"); #else float h = Input.GetAxis("Horizontal"); #endif // Pass all parameters to the character control script. character.UpdateState(_robotInput); }
// Update is called once per frame void Update() { //------------Player movement And Fire Button-------------// #if CROSS_PLATFORM_INPUT rotation = -CrossPlatformInput.GetAxis("Horizontal"); acceleration = Mathf.Lerp(CrossPlatformInput.GetAxis("Vertical") * accelerationForce, 0f, 0.8f); if (CrossPlatformInput.GetButtonDown("Jump")) { BulleteFire(); } # else
/// <summary> /// Get the altitude the player wants the avatar to be. /// </summary> /// <param name="altitudeRange">The height range the avatar is allowed to move on the Y axis.</param> /// <returns>The altitude the player wants the avatar to be.</returns> private static float GetTargetAltitude(float altitudeRange = 3f) { #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBGL var normalizedMousePosition = Input.mousePosition.y / Screen.height; var altitude = Mathf.Clamp((normalizedMousePosition - 0.5f) * -2, -1f, 1f); #else var altitude = CrossPlatformInput.GetAxis("Vertical"); #endif altitude *= altitudeRange; // Round off the tilt input return(Mathf.Round(altitude * 100f) / 100f); }
void HandleRotationMovement() { // Read the user input #if CROSS_PLATFORM_INPUT var x = CrossPlatformInput.GetAxis("Mouse X"); var y = CrossPlatformInput.GetAxis("Mouse Y"); #else var x = Input.GetAxis("Mouse X"); var y = Input.GetAxis("Mouse Y"); #endif // smooth the user input if (turnSmoothing > 0) { smoothX = Mathf.SmoothDamp(smoothX, x, ref smoothXvelocity, turnSmoothing); smoothY = Mathf.SmoothDamp(smoothY, y, ref smoothYvelocity, turnSmoothing); } else { smoothX = x; smoothY = y; } // Adjust the look angle by an amount proportional to the turn speed and horizontal input. lookAngle += smoothX * turnSpeed; // Rotate the rig (the root object) around Y axis only: transform.rotation = Quaternion.Euler(0f, lookAngle, 0f); #if MOBILE_INPUT // For tilt input, we need to behave differently depending on whether we're using mouse or touch input: // on mobile, vertical input is directly mapped to tilt value, so it springs back automatically when the look input is released // we have to test whether above or below zero because we want to auto-return to zero even if min and max are not symmetrical. if (y > 0) { tiltAngle = Mathf.Lerp(0, -tiltMin, smoothY); } if (y <= 0) { tiltAngle = Mathf.Lerp(0, tiltMax, -smoothY); } #else // on platforms with a mouse, we adjust the current angle based on Y mouse input and turn speed tiltAngle -= smoothY * turnSpeed; // and make sure the new value is within the tilt range tiltAngle = Mathf.Clamp(tiltAngle, -tiltMin, tiltMax); #endif // Tilt input around X is applied to the pivot (the child of this object) pivot.localRotation = Quaternion.Euler(z.V_LookAngle, 0f, 0f); }
void FixedUpdate() { #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); #else float h = Input.GetAxis("Horizontal"); #endif // Pass all parameters to the character control script. character.Move(h, jump); // Reset the jump input once it has been used. jump = false; }
private void FixedUpdate() { bool key = Input.GetKey(KeyCode.C); bool button = CrossPlatformInput.GetButton("Jump"); float axis = CrossPlatformInput.GetAxis("Horizontal"); float axis2 = CrossPlatformInput.GetAxis("Vertical"); Vector3 normalized = Vector3.Scale(this.cam.forward, new Vector3(1f, 0f, 1f)).normalized; Vector3 vector = axis2 * normalized + axis * this.cam.right; bool key2 = Input.GetKey(KeyCode.LeftShift); float d = (!this.walkByDefault) ? ((!key2) ? 1f : 0.5f) : ((!key2) ? 0.5f : 1f); vector *= d; this.lookPos = ((!this.lookInCameraDirection || !(this.cam != null)) ? (base.transform.position + base.transform.forward * 100f) : (base.transform.position + this.cam.forward * 100f)); this.character.Move(vector, key, button, this.lookPos); }
void FixedUpdate() { // pass the input to the car! #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); #else float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif if (isKeyboardControlled) { //Debug.Log ( h + " , " +v ); car.Move(h, v); } }
void FixedUpdate() { // Read the inputs. //bool crouch = Input.GetKey(KeyCode.LeftControl); #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); #else float h = Input.GetAxis("Horizontal"); #endif // Pass all parameters to the character control script. character.Move(h, false, jump); // Reset the jump input once it has been used. jump = false; }
void FixedUpdate() { jumpActive = Input.GetKey(KeyCode.Space); bool nitro = Input.GetKeyDown(KeyCode.LeftShift); // pass the input to the car! #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); //jumpActive = CrossPlatformInput.GetButton("Jump"); #else float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif car.Move(h, v, jumpActive, nitro); }
void FixedUpdate() { // Read input for the pitch, yaw, roll and throttle of the aeroplane. float roll = CrossPlatformInput.GetAxis("Mouse X"); float pitch = CrossPlatformInput.GetAxis("Mouse Y"); float yaw = CrossPlatformInput.GetAxis("Horizontal"); float throttle = CrossPlatformInput.GetAxis("Vertical"); AdjustInputForMobileControls(ref roll, ref pitch, ref throttle); // Read input for the air brakes. var airBrakes = CrossPlatformInput.GetButton("Fire1"); // Pass the input to the aeroplane aeroplane.Move(roll, pitch, yaw, throttle, airBrakes); }
void Update() { // Get the axis and jump input. #if CROSS_PLATFORM_INPUT jump = CrossPlatformInput.GetButton("Jump"); float h = CrossPlatformInput.GetAxis("Horizontal"); float v = CrossPlatformInput.GetAxis("Vertical"); #else jump = Input.GetButton("Jump"); float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); #endif /* if (h > 0) { * ballDir = Direction.RIGHT; * } else if (h < 0) { * ballDir = Direction.LEFT; * } * if (v > 0) { * ballDir = Direction.UP; * } else if (v < 0) { * ballDir = Direction.DOWN; * } * * if (ballOldDir != ballDir) { * ballOldDir = ballDir; * ball.rigidbody.velocity = Vector3.zero; * ball.rigidbody.angularVelocity = Vector3.zero; * } */ // calculate move direction if (cam != null) { // calculate camera relative direction to move: camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; move = (v * camForward + h * cam.right).normalized; } else { // we use world-relative directions in the case of no main camera move = (v * Vector3.forward + h * Vector3.right).normalized; } }
void FixedUpdate() { // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground grounded = Physics2D.OverlapCircle(groundCheck.position, groundedRadius, whatIsGround); anim.SetBool("Ground", grounded); // Read the inputs. bool crouch = Input.GetKey(KeyCode.LeftControl); #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); #else float h = Input.GetAxis("Horizontal"); #endif Move(h); // Set the vertical animation //anim.SetFloat("vSpeed", rigidbody2D.velocity.y); }
void Update() { grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround); anim.SetBool("Ground", grounded); if (grounded) { doubleJump = false; } anim.SetFloat("vSpeed", rigidbody2D.velocity.y); #if MOBILE_INPUT jump = CrossPlatformInput.GetButton("Jump"); xAxisValue = CrossPlatformInput.GetAxis("Horizontal"); #endif #if UNITY_EDITOR jump = Input.GetButtonDown("Jump"); xAxisValue = Input.GetAxis("Horizontal"); #endif //anim.SetFloat ("Speed", Mathf.Abs (xAxisValue)); rigidbody2D.velocity = new Vector2(xAxisValue * maxSpeed, rigidbody2D.velocity.y); if (xAxisValue > 0 && !facingRight) { Flip(); } else if (xAxisValue < 0 && facingRight) { Flip(); } if (jump) { Jump(); } }
private void HandleRotationMovement() { float axis = CrossPlatformInput.GetAxis("Mouse X"); float axis2 = CrossPlatformInput.GetAxis("Mouse Y"); if (this.turnSmoothing > 0f) { this.smoothX = Mathf.SmoothDamp(this.smoothX, axis, ref this.smoothXvelocity, this.turnSmoothing); this.smoothY = Mathf.SmoothDamp(this.smoothY, axis2, ref this.smoothYvelocity, this.turnSmoothing); } else { this.smoothX = axis; this.smoothY = axis2; } this.lookAngle += this.smoothX * this.turnSpeed; base.transform.rotation = Quaternion.Euler(0f, this.lookAngle, 0f); this.tiltAngle -= this.smoothY * this.turnSpeed; this.tiltAngle = Mathf.Clamp(this.tiltAngle, -this.tiltMin, this.tiltMax); this.pivot.localRotation = Quaternion.Euler(this.tiltAngle, 0f, 0f); }
void FixedUpdate() { if (Input.GetKey(KeyCode.Escape)) { Application.LoadLevel("MainMenu"); } // Read the inputs. bool attack = Input.GetKey(KeyCode.Mouse0) | Input.GetKey(KeyCode.J); bool convert = Input.GetKey(KeyCode.F) | Input.GetKey(KeyCode.K); #if CROSS_PLATFORM_INPUT float h = CrossPlatformInput.GetAxis("Horizontal"); #else float h = Input.GetAxis("Horizontal"); #endif // Pass all parameters to the character control script. character.Move(h, attack, jump, convert); // Reset the jump input once it has been used. jump = false; }
void FixedUpdate() { if (CurrentMode == Mode.Playing) { float h = CrossPlatformInput.GetAxis("Horizontal"); // Pass all parameters to the character control script. character.Move(h, jump); // Reset the jump input once it has been used. jump = false; // Check if we need to rotate the level if (rotationDirection != RotateDirection.None) { // Rotate the room rotateEverything.Rotate(rotationDirection); gravityAudio.Play(); rotationDirection = RotateDirection.None; } } }