// Update is called once per frame void Update() { //get player input for motion Vector3 motionInput = Sinput.GetVector("Horizontal", "", "Vertical", playerSlot); //we want to move like, three times as much as this motionInput *= 3f; //gravity yMotion -= Time.deltaTime * 10f; motionInput.y = yMotion; //move our character controller now characterController.Move(motionInput * Time.deltaTime); if (characterController.isGrounded) { yMotion = -0.05f; if (Sinput.GetButtonDown("Jump", playerSlot)) { yMotion = 5f; } } }
void Move(float lh, float lv) { if (inMenu == false) { movement.Set(lh, 0f, lv); movement = Camera.main.transform.TransformDirection(movement); movement.y = 0f; if (Sinput.GetButtonDown("Jump") && isGrounded) { Jump(); } myRB.AddForce(movement * speed); if (lh != 0f || lv != 0f) { Rotating(lh, lv); } if (myRB.velocity.magnitude > maxSpeed) { myRB.velocity = myRB.velocity.normalized * maxSpeed; } } }
public void HandleLeftRightMovement() { hInput = Sinput.GetAxisRaw("Horizontal"); spriteRenderer.flipX = hInput != 0 ? hInput < 0 : spriteRenderer.flipX; //this sorta weird setup means that the player can still MOVE really fast (if propelled by external forces) //its just that he cant go super fast just by player input alone //force should be clamped so it doesnt let velocity extend past currentSpeed var force = accel * hInput * Time.deltaTime * 100; force = Mathf.Clamp(force + velocity.x, -currentSpeed, currentSpeed) - velocity.x; //basically making sure the adjusted force of the input doesn't act against the input itself if (Mathf.Sign(force) == Mathf.Sign(hInput)) { velocity.x += force; } if (Mathf.Abs(hInput) < 0.01f) { velocity.x *= 0.8f; } }
// Update is called once per frame void Update() { fsm.Update(); if (this.combo > 1) { comboKillTimer -= Time.deltaTime; //this.comboMeter.fillAmount = MathUtil.Map(this.comboKillTimer, this.comboKillTime, 0, 0, 1); if (comboKillTimer <= 0) { //this.DecrementCombo(); comboKillTimer = comboKillTime; } } if (GameManager.instance.paused) { Time.timeScale = 0; } else { Time.timeScale = 1; } if (Sinput.GetButtonDown("Pause")) { GameManager.instance.pausedForPauseScreen = !GameManager.instance.pausedForPauseScreen; GameManager.instance.paused = !GameManager.instance.paused; } if (Sinput.GetButtonDown("Restart")) { SceneManager.LoadSceneAsync(0); } }
// Update is called once per frame void Update() { if (Sinput.GetButtonDownRepeating("Up")) { //highlight item above currentMenuItem.highlighted = false; currentMenuItem = currentMenuItem.itemAbove; currentMenuItem.highlighted = true; } if (Sinput.GetButtonDownRepeating("Down")) { //highlight item below currentMenuItem.highlighted = false; currentMenuItem = currentMenuItem.itemBelow; currentMenuItem.highlighted = true; } if (Sinput.GetButtonDown("Submit")) { //select this item currentMenuItem.Select(); Sinput.ResetInputs(); } cam.position = Vector3.Lerp(cam.position, currentMenuItem.camTargetPos.position, Time.deltaTime * 4f); cam.rotation = Quaternion.Slerp(cam.rotation, currentMenuItem.camTargetPos.rotation, Time.deltaTime * 4f); cursor.position = currentMenuItem.cursorTarget.position; }
public bool ButtonCheck(ButtonAction bAction, InputDeviceSlot slot) { if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(positiveControl, slot)) { return(true); } if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(negativeControl, slot)) { return(true); } if (bAction == ButtonAction.HELD && Sinput.GetButton(positiveControl, slot)) { return(true); } if (bAction == ButtonAction.HELD && Sinput.GetButton(negativeControl, slot)) { return(true); } if (bAction == ButtonAction.UP && Sinput.GetButtonUp(positiveControl, slot)) { return(true); } if (bAction == ButtonAction.UP && Sinput.GetButtonUp(negativeControl, slot)) { return(true); } return(false); }
private bool ButtonCheck(string controlname, ButtonAction bAction) { Sinput.SinputUpdate(); for (int i = 0; i < joystickIndeces.Count; i++) { if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(controlname, (InputDeviceSlot)joystickIndeces[i])) { return(true); } if (bAction == ButtonAction.HELD && Sinput.GetButton(controlname, (InputDeviceSlot)joystickIndeces[i])) { return(true); } if (bAction == ButtonAction.UP && Sinput.GetButtonUp(controlname, (InputDeviceSlot)joystickIndeces[i])) { return(true); } if (bAction == ButtonAction.REPEATING && Sinput.GetButtonDownRepeating(controlname, (InputDeviceSlot)joystickIndeces[i])) { return(true); } } return(false); }
public override void Process() { bool usedEvent = SendUpdateEventToSelectedObject(); m_InputDeviceSlot = (InputDeviceSlot)Enum.Parse(typeof(InputDeviceSlot), m_InputSlotter); if (eventSystem.sendNavigationEvents) { if (!usedEvent) { usedEvent |= SendMoveEventToSelectedObject(); } if (!usedEvent) { //SendSubmitEventToSelectedObject(); if (SendSubmitEventToSelectedObject()) { Sinput.ResetInputs(); } } } ProcessMouseEvent(); }
private float AxisCheck(string controlname, bool getRawValue = false) { Sinput.SinputUpdate(); float returnV = 0f; float v = 0f; for (int i = 0; i < joystickIndeces.Count; i++) { if (!getRawValue) { v = Sinput.GetAxis(controlname, (InputDeviceSlot)joystickIndeces[i]); } else { v = Sinput.GetAxisRaw(controlname, (InputDeviceSlot)joystickIndeces[i]); } if (Mathf.Abs(v) > Mathf.Abs(returnV)) { returnV = v; } } return(returnV); }
void Init() { //Debug.Log("Loading Default controls"); /*Sinput.LoadControlScheme("MainControlScheme", false); * controlsDefaults = Sinput.controls; * * //Debug.Log("loading controls with saved data"); * Sinput.LoadControlScheme("MainControlScheme", true); * controls = Sinput.controls;*/ Sinput.LoadControlScheme("MainControlScheme", false); Control[] sinputControls = Sinput.controls; controlsDefaults = new Control[sinputControls.Length]; for (int i = 0; i < sinputControls.Length; i++) { controlsDefaults[i] = new Control(sinputControls[i].name); for (int k = 0; k < sinputControls[i].commonMappings.Count; k++) { controlsDefaults[i].commonMappings.Add(sinputControls[i].commonMappings[k]); } controlsDefaults[i].inputs = new List <DeviceInput>(); for (int k = 0; k < sinputControls[i].inputs.Count; k++) { controlsDefaults[i].inputs.Add(sinputControls[i].inputs[k]); } } //Debug.Log("loading controls with saved data"); Sinput.LoadControlScheme("MainControlScheme", true); sinputControls = Sinput.controls; controls = new Control[sinputControls.Length]; for (int i = 0; i < sinputControls.Length; i++) { controls[i] = new Control(sinputControls[i].name); for (int k = 0; k < sinputControls[i].commonMappings.Count; k++) { controls[i].commonMappings.Add(sinputControls[i].commonMappings[k]); } controls[i].inputs = new List <DeviceInput>(); for (int k = 0; k < sinputControls[i].inputs.Count; k++) { controls[i].inputs.Add(sinputControls[i].inputs[k]); } } recordedPads = Sinput.gamepads; //Debug.Log("It should be over?"); BuildRebindingPanels(); }
void FixedUpdate() { float lh = Sinput.GetAxisRaw("Horizontal"); float lv = Sinput.GetAxisRaw("Vertical"); Move(lh, lv); FlashlightBob(); }
public static bool IsValidKey() { return(Input.GetMouseButtonDown(0) || Sinput.GetButtonDown(GetInputName(InputButton.A)) || Sinput.GetButtonDown(GetInputName(InputButton.B)) || Sinput.GetButtonDown(GetInputName(InputButton.X)) || Sinput.GetButtonDown(GetInputName(InputButton.Y)) || Sinput.GetButtonDown(GetInputName(InputButton.DPadLeft)) || Sinput.GetButtonDown(GetInputName(InputButton.DPadRight)) || Sinput.GetButtonDown(GetInputName(InputButton.DPadDown)) || Sinput.GetButtonDown(GetInputName(InputButton.DPadUp)) || Sinput.GetButtonDown("LB") || Sinput.GetButtonDown("RB")); }
public void Ground_Update() { PlayerAnim currentAnim = PlayerAnim.Idle; if (hInput != 0) { currentAnim = this.objectBeingCarried ? PlayerAnim.Carry_Walk : PlayerAnim.Walk; } else { currentAnim = this.objectBeingCarried ? PlayerAnim.Carry_Idle : PlayerAnim.Idle; } if (!animator.IsPlaying(animations[currentAnim])) { PlayAnim(currentAnim); } //END ANIMATION STUFF if (objectBeingCarried) { HandleObjectThrow(); } else { CheckGrabs(); } this.currentSpeed = this.speed; if (Sinput.GetButtonDown("Jump")) { SfxManager.instance.PlaySound(SoundType.JUMP); Squash(0.05f).Then(() => { Stretch(); velocity.y = jumpSpeed; }); } if (Sinput.GetButtonDown("Down")) { if (groundCollider.CompareTag("OneWay")) { transform.position += Vector3.down * 0.5f; } } this.currentGravityModifier = this.gravityModifier; //STATE CHANGES if (!grounded) { fsm.ChangeState(PlayerState.Air); } HandleLeftRightMovement(); }
public void Update() { foreach (var inputNameToCheckFor in INPUT_NAMES_TO_CHECK_FOR) { if (Sinput.GetButtonDown(inputNameToCheckFor, _playerData.InputDeviceSlot)) { InvokeInputPressed(inputNameToCheckFor); } } }
public void Air_Update() { if (this.velocity.y > 0) { PlayAnim(this.objectBeingCarried ? PlayerAnim.Carry_Jump : PlayerAnim.Jump); } else { PlayAnim(this.objectBeingCarried ? PlayerAnim.Carry_Fall : PlayerAnim.Fall); } if (Sinput.GetButtonUp("Jump")) { velocity.y *= 0.5f; } if (velocity.y > 0) { this.currentGravityModifier = this.gravityModifier; } else { this.currentGravityModifier = this.fallGravityModifier; } if (grounded) { fsm.ChangeState(PlayerState.Ground); } if (Sinput.GetButtonDown("Jump") && !doubleJumped) { doubleJumped = true; SfxManager.instance.PlaySound(SoundType.JUMP); Stretch(); velocity.y = jumpSpeed; } if (Sinput.GetButtonDown("Down") && objectBeingCarried && objectBeingCarried.GetComponent <Slime>()) { objectBeingCarried.transform.parent = null; objectBeingCarried.transform.position += Vector3.down * (spriteRenderer.bounds.size.y); objectBeingCarried.Throw(0); objectBeingCarried = null; objectToGrab = null; } HandleLeftRightMovement(); HandleObjectThrow(); if (!objectBeingCarried) { CheckGrabs(); } }
public void HandleObjectThrow() { if (!objectBeingCarried) { return; } if (Sinput.GetButtonDown("Grab")) { fsm.ChangeState(PlayerState.Throwing); } }
void move() { float horizontal, vertical; horizontal = Sinput.GetAxis("Horizontal", slot); vertical = Sinput.GetAxis("Vertical", slot); if (Mathf.Abs(horizontal) >= moveInputThreshhold || Mathf.Abs(vertical) >= moveInputThreshhold) { playerMovement.move(Sinput.GetAxis("Horizontal", slot), Sinput.GetAxis("Vertical", slot)); } }
private void InitializeMouseSensitivity() { // this is a really janky way to set the mouse sensitivity to .2f by default to balance out the controller input if (!PlayerPrefs.HasKey("OneTimeRun.MouseSensitivity")) { Sinput.LoadControlScheme("MainControlScheme", true); // need to load it before we can save it Sinput.mouseSensitivity = .2f; // initialize it once SinputSystems.SinputFileIO.SaveControls(Sinput.controls, Sinput.controlSchemeName); PlayerPrefs.SetString("OneTimeRun.MouseSensitivity", "done"); } }
// Update is called once per frame void Update() { SinputSystems.InputDeviceSlot slot = Sinput.GetSlotPress("Join"); if (slot != SinputSystems.InputDeviceSlot.any) { GameObject newPlayer = (GameObject)GameObject.Instantiate(playerPrefab); newPlayer.transform.position = new Vector3(Random.Range(-4f, 4f), 3f, Random.Range(-4f, 4f)); newPlayer.GetComponent <MultiplayerPlayer>().playerSlot = slot; } }
public static void SetVirtualAxis(string virtualInputName, float newAxisValue) { Sinput.SinputUpdate(); //make sure sinput is set up, so any bound virtual inputs have been instantiated for (int i = 0; i < inputs.Count; i++) { if (inputs[i].name == virtualInputName) { inputs[i].SetAxisValue(newAxisValue); return; } } Debug.Log("Virtual input \"" + virtualInputName + "\" not found."); }
public static void SetDeltaPreference(string virtualInputName, bool preferFrameDelta) { Sinput.SinputUpdate(); //make sure sinput is set up, so any bound virtual inputs have been instantiated for (int i = 0; i < inputs.Count; i++) { if (inputs[i].name == virtualInputName) { inputs[i].preferDeltaUse = preferFrameDelta; return; } } Debug.Log("Virtual input \"" + virtualInputName + "\" not found."); }
public static void SetVirtualButtonHeld(string virtualInputName, bool held) { Sinput.SinputUpdate(); //make sure sinput is set up, so any bound virtual inputs have been instantiated for (int i = 0; i < inputs.Count; i++) { if (inputs[i].name == virtualInputName) { inputs[i].UpdateButtonState(held); return; } } Debug.Log("Virtual input \"" + virtualInputName + "\" not found."); }
private IEnumerator ButtonHighlight(InputManager.InputButton btn) { Image btnImage = GetBtnImage(btn); btnImage.color = btnColors.buttonColorsList.Find(bt => bt.button == btn).color; yield return(new WaitWhile(() => Sinput.GetButton(InputManager.GetInputName(btn)))); while (Vector4.Distance(btnImage.color, Color.white) > 0.05f) { btnImage.color = Color.Lerp(btnImage.color, Color.white, Time.deltaTime * 2f); yield return(null); } }
private void Update() { if (Sinput.GetButtonDown("Menu")) { // then toggle pause! isPaused = !isPaused; if (isPaused) { PauseGame(); } else { ResumeGame(); } } }
private void AddGamepadInput(CommonXRInputs gamepadButtonOrAxis, bool isNewBinding) { Sinput.CheckGamepads(); if (isNewBinding) { commonXRMappings.Add(gamepadButtonOrAxis); } List <DeviceInput> applicableMapInputs = CommonGamepadMappings.GetApplicableMaps(CommonGamepadInputs.NOBUTTON, gamepadButtonOrAxis, Sinput.gamepads); for (int i = 0; i < applicableMapInputs.Count; i++) { applicableMapInputs[i].commonMappingType = CommonGamepadInputs.NOBUTTON; } AddGamepadInputs(applicableMapInputs); }
// Update is called once per frame private void Update() { if (m_pauseMenu != null && m_pauseMenu.isActiveAndEnabled) { return; } float deltaTime = Time.deltaTime; Vector3 pos = transform.position; float cameraSize = m_camera.orthographicSize; if (Sinput.GetButtonRaw("Left")) { pos.x -= m_moveSensitivity * deltaTime; } if (Sinput.GetButtonRaw("Right")) { pos.x += m_moveSensitivity * deltaTime; } if (Sinput.GetButtonRaw("Up")) { pos.y += m_moveSensitivity * deltaTime; } if (Sinput.GetButtonRaw("Down")) { pos.y -= m_moveSensitivity * deltaTime; } if (Sinput.GetButtonRaw("ZoomIn")) { cameraSize -= m_zoomSensitivity * deltaTime; } if (Sinput.GetButtonRaw("ZoomOut")) { cameraSize += m_zoomSensitivity * deltaTime; } cameraSize = Mathf.Clamp(cameraSize, 10, 75); pos.x = Mathf.Clamp(pos.x, -m_cameraBounds + cameraSize, m_cameraBounds - cameraSize); pos.y = Mathf.Clamp(pos.y, -m_cameraBounds + cameraSize, m_cameraBounds - cameraSize); transform.position = pos; m_camera.orthographicSize = cameraSize; }
private IEnumerator CheckPress() { while (Sinput.GetButton(_button)) { if (Sinput.GetButtonDown("RB")) { _audioSource.pitch += 0.1f; } if (Sinput.GetButtonDown("LB")) { _audioSource.pitch -= 0.1f; } yield return(null); } Destroy(gameObject); }
private void Update() { if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadLeft))) { CoroutineThing(InputManager.InputButton.DPadLeft, ref _dpadleftCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadRight))) { CoroutineThing(InputManager.InputButton.DPadRight, ref _dpadrightCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadDown))) { CoroutineThing(InputManager.InputButton.DPadDown, ref _dpaddownCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadUp))) { CoroutineThing(InputManager.InputButton.DPadUp, ref _dpadupCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.A))) { CoroutineThing(InputManager.InputButton.A, ref _aCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.B))) { CoroutineThing(InputManager.InputButton.B, ref _bCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.X))) { CoroutineThing(InputManager.InputButton.X, ref _xCoroutine); } if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.Y))) { CoroutineThing(InputManager.InputButton.Y, ref _yCoroutine); } }
void Update() { if (PlayerNumber == 1) { _playerAxis = Sinput.GetVector("Horizontal", "Vertical", _playerSlot1) * Time.deltaTime * 50f; } if (PlayerNumber == 2) { _playerAxis = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical") * Time.deltaTime * 50f); //_playerAxis = Sinput.GetVector("Horizontal", "Vertical", _playerSlot2) * Time.deltaTime * 50f; } if (!_forceAdded) { _forceAdded = true; _fishRigidbody.AddForce(_playerAxis, ForceMode2D.Impulse); _forceAdded = false; } ClampingVelocity(_zRot); }
private new bool SendSubmitEventToSelectedObject() { if (eventSystem.currentSelectedGameObject == null) { return(false); } var data = GetBaseEventData(); if (Sinput.GetButtonDown(m_SinputSubmitButton)) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler); } if (Sinput.GetButtonDown(m_SinputCancelButton)) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler); } return(data.used); }