// ------------ Public Methods --------------- // // >>> For Buttons <<< // /// <summary> /// Returns <c>true</c> if the specified button is held down by any controller. /// </summary> /// <param name='button'> /// Identifier for the Xbox button to be tested. /// </param> public static bool GetButton(XboxButton button) { if (button.IsDPad()) return GetDPad(button.ToDPad()); if(OnWindowsNative()) { if(!XInputStillInCurrFrame()) { XInputUpdateAllStates(); } GamePadState ctrlrState = XInputGetSingleState(); if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) { return true; } } else { string btnCode = DetermineButtonCode(button, 0); if(Input.GetKey(btnCode)) { return true; } } return false; }
void OnButton(int joyNumber, XboxButton btn) { if(btn == XboxButton.buttonB) { Application.LoadLevel("mainmenu"); } }
/* * INPUT VALUES IN INPUTMANAGER FOR PLAYER #: * * Left Joystick: P#LeftStickX * Right Joystick: P#RightStickX * */ public static bool GetButton(XboxButton button, XboxController controller) { #if UNITY_EDITOR int controllerNum = Ctrl2Num(controller); if (XCI.GetNumPluggedCtrlrs() >= controllerNum) { return(XCI.GetButton(button, controller)); } else { return(Input.GetButton("P" + controllerNum + button)); } #else return(XCI.GetButton(button, controller)); #endif }
void OnButton(int joyNumber, XboxButton btn) { if(btn == XboxButton.buttonA) { Application.LoadLevel("gameplay"); } else if(btn == XboxButton.buttonB) { Application.LoadLevel("how to"); } else if(btn == XboxButton.buttonX) { Application.LoadLevel("credits"); } }
private void GetNextButtonToPress() { if (isRandom) { buttonToPress = possibleButtons[Random.Range(0, possibleButtons.Count)]; } else { buttonToPress = buttonsPattern[currentButtonIndex]; } if (!actionableObject.PatternButtonAnim) { print("error in " + gameObject.name); } Invoke(nameof(setButtonToPress), 2 / 60f); // actionableObject.PatternButtonAnim.SetTrigger(MiniGame.ButtonAnimations[buttonToPress]); // Debug.Log("SetTrigger " + MiniGame.ButtonAnimations[buttonToPress]); }
static Texture2D PostInitTranslator(Texture2D __result, XboxButton button) { if (button == XboxButton.X && _interactTexture) { return(_interactTexture); } if (button == XboxButton.Y && _holdTexture) { return(_holdTexture); } if (button == XboxButton.B && _backTexture) { return(_backTexture); } if (button == XboxButton.A && _jumpTexture) { return(_jumpTexture); } return(__result); }
public override bool GetButtonDown(XboxButton button) { KeyCode code; if (buttonMapping.TryGetValue(button, out code)) { if (Input.GetKeyDown(code)) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> Returns <c>true</c> at the frame the specified button is released by a specified controller. </summary> /// <param name='button'> Identifier for the Xbox button to be tested. </param> /// <param name='controllerNumber'> An identifier for the specific controller on which to test the button. An int between 1 and 4. </param> public static bool GetButtonUp(XboxButton button, int controllerNumber) { if (!IsControllerNumberValid(controllerNumber)) { return(false); } if (OnWindowsNative()) { if (Time.frameCount < 2) { return(false); } if (!XInputStillInCurrFrame()) { XInputUpdateAllStates(); //XInputUpdatePaticularState(controllerNumber); } GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); if ((XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released) && (XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed)) { return(true); } } else { string btnCode = DetermineButtonCode(button, controllerNumber); if (Input.GetKeyUp(btnCode)) { return(true); } } return(false); }
public static XboxCustomFunction GetFunction(XboxButton button) { switch (button) { case XboxButton.Start: return(XboxCustomFunction.Button_Start); case XboxButton.Back: return(XboxCustomFunction.Button_Back); case XboxButton.LeftThumb: return(XboxCustomFunction.Left_Thumb); case XboxButton.RightThumb: return(XboxCustomFunction.Right_Thumb); case XboxButton.LeftBumper: return(XboxCustomFunction.Left_Bumper); case XboxButton.RightBumper: return(XboxCustomFunction.Right_Bumper); case XboxButton.Guide: return(XboxCustomFunction.Button_Guide); case XboxButton.A: return(XboxCustomFunction.Button_A); case XboxButton.B: return(XboxCustomFunction.Button_B); case XboxButton.X: return(XboxCustomFunction.Button_X); case XboxButton.Y: return(XboxCustomFunction.Button_Y); default: throw new NotImplementedException("Not implemented xbox button:" + button); } }
void ButtonControlsXInput(int i) { XboxButton val = myXCIButtons[i].GetXboxButtonCode(); if (XCI.GetButtonDown(val, xboxController)) { if (s_GameManager.ShowDebug() || ShowDebug) { Debug.Log(val.ToString() + " is value of down"); } myXCIButtons[i].Execute(); } if (XCI.GetButtonUp(val, xboxController)) { if (s_GameManager.ShowDebug() || ShowDebug) { Debug.Log(val.ToString() + " is value of up"); } myXCIButtons[i].ExecuteOnUp(); } }
static bool SingleAxisUpdate( SingleAxisCommand __instance, XboxButton ____xboxButtonPositive, XboxButton ____xboxButtonNegative, ref float ____value, ref bool ____newlyPressedThisFrame, ref float ____lastValue, ref float ____lastPressedDuration, ref float ____pressedDuration, ref float ____realtimeSinceLastUpdate ) { if (____xboxButtonPositive == XboxButton.None && ____xboxButtonNegative == XboxButton.None) { return(true); } ____newlyPressedThisFrame = false; ____lastValue = ____value; ____value = 0f; if (_buttons.ContainsKey(____xboxButtonPositive)) { ____value += _buttons[____xboxButtonPositive]; } if (_buttons.ContainsKey(____xboxButtonNegative)) { ____value -= _buttons[____xboxButtonNegative]; } ____lastPressedDuration = ____pressedDuration; ____pressedDuration = ((!__instance.IsPressed()) ? 0f : (____pressedDuration + (Time.realtimeSinceStartup - ____realtimeSinceLastUpdate))); ____realtimeSinceLastUpdate = Time.realtimeSinceStartup; return(false); }
void OnButton(int joyNumber, XboxButton btn) { if(Time.timeSinceLevelLoad > 12) { print ("APertando " + btn.ToString()); if(btn == XboxButton.buttonA) { Application.LoadLevel("gameplay"); } else if(btn == XboxButton.buttonB) { Application.LoadLevel("how to"); } else if(btn == XboxButton.buttonX) { Application.LoadLevel("credits"); } } }
void OnButton(int joyNumber, XboxButton btn) { if(btn == XboxButton.buttonA) { if(currPage < 2) { currPage++; GetComponent<GUITexture>().texture = pages[currPage]; } else { Application.LoadLevel("mainmenu"); } } else if(btn == XboxButton.buttonB) { if(currPage > 0) { currPage--; GetComponent<GUITexture>().texture = pages[currPage]; } } }
void OnButton(int joyNumber, XboxButton btn) { print ("Joy " + joyNumber + " Pressed " + btn.ToString()); if(_joyNumber != joyNumber) return; if(onButtonDown != null) { onButtonDown(btn); } if(!GetComponent<SpriteRenderer>().enabled && btn == XboxButton.buttonStart) { GetComponent<PlayerLogic>().enabled = true; GetComponent<PlayerView>().enabled = true; GetComponent<SpriteRenderer>().enabled = true; GetComponent<Collider>().enabled = true; gameObject.SetActive(true); for(int i = 0; i < transform.childCount; i++) transform.GetChild(i).gameObject.SetActive(true); } }
int getIndexOfXboxButton(XboxButton val) { int valI = (int)val; int indexToCheck = XCIMyKeyButtonLocation.Count / 2; int timesRound = 0; int l = 0; int r = XCIMyKeyButtonLocation.Count - 1; while (l <= r) { int m = l + (r - l) / 2; if (XCIMyKeyButtonLocation[m].Key == valI) // Check if valI is present at mid { return(m); } if (XCIMyKeyButtonLocation[m].Key < valI) // If valI greater, ignore left half { l = m + 1; } else // If valI is smaller, ignore right half { r = m - 1; } timesRound++; if (timesRound > 150) { Debug.Log("Failed to find index, breaking loop"); break; } } Debug.LogError("Unable to find value"); return(-1); }
public VirtualButton(XboxController controller, XboxButton button) { m_ControllerId = controller; m_Button = button; }
static IEnumerator <WaitForSecondsRealtime> ResetInput(XboxButton button) { yield return(new WaitForSecondsRealtime(0.1f)); SimulateInput(button, 0); }
public static bool GetButtonValue(uint userIndex, XboxButton button) { return(states[(int)userIndex - 1].ButtonsDown.Contains(button)); }
public Kick(s_Player p, XboxButton kc) : base(p, kc) { }
SteamVR_Action_Boolean.ChangeHandler CreateButtonHandler(XboxButton button) { return((SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) => { _buttons[button] = newState ? 1 : 0; }); }
//>> For getting input << private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) { ButtonState stateToReturn = ButtonState.Pressed; switch(xciBtn) { case XboxButton.A: stateToReturn = xiButtons.A; break; case XboxButton.B: stateToReturn = xiButtons.B; break; case XboxButton.X: stateToReturn = xiButtons.X; break; case XboxButton.Y: stateToReturn = xiButtons.Y; break; case XboxButton.Start: stateToReturn = xiButtons.Start; break; case XboxButton.Back: stateToReturn = xiButtons.Back; break; case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; } return stateToReturn; }
private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) { string r = ""; string sJoyCode = ""; string sKeyCode = ""; bool invalidCode = false; if (ctrlrNum == 0) { sJoyCode = ""; } else { sJoyCode = " " + ctrlrNum.ToString(); } if (OnMac()) { switch (btn) { case XboxButton.A: sKeyCode = "16"; break; case XboxButton.B: sKeyCode = "17"; break; case XboxButton.X: sKeyCode = "18"; break; case XboxButton.Y: sKeyCode = "19"; break; case XboxButton.Start: sKeyCode = "9"; break; case XboxButton.Back: sKeyCode = "10"; break; case XboxButton.LeftStick: sKeyCode = "11"; break; case XboxButton.RightStick: sKeyCode = "12"; break; case XboxButton.LeftBumper: sKeyCode = "13"; break; case XboxButton.RightBumper: sKeyCode = "14"; break; default: invalidCode = true; break; } } else if (OnLinux()) { switch (btn) { case XboxButton.A: sKeyCode = "0"; break; case XboxButton.B: sKeyCode = "1"; break; case XboxButton.X: sKeyCode = "2"; break; case XboxButton.Y: sKeyCode = "3"; break; case XboxButton.Start: sKeyCode = "7"; break; case XboxButton.Back: sKeyCode = "6"; break; case XboxButton.LeftStick: sKeyCode = "9"; break; case XboxButton.RightStick: sKeyCode = "10"; break; case XboxButton.LeftBumper: sKeyCode = "4"; break; case XboxButton.RightBumper: sKeyCode = "5"; break; default: invalidCode = true; break; } } else { switch (btn) { case XboxButton.A: sKeyCode = "0"; break; case XboxButton.B: sKeyCode = "1"; break; case XboxButton.X: sKeyCode = "2"; break; case XboxButton.Y: sKeyCode = "3"; break; case XboxButton.Start: sKeyCode = "7"; break; case XboxButton.Back: sKeyCode = "6"; break; case XboxButton.LeftStick: sKeyCode = "8"; break; case XboxButton.RightStick: sKeyCode = "9"; break; case XboxButton.LeftBumper: sKeyCode = "4"; break; case XboxButton.RightBumper: sKeyCode = "5"; break; default: invalidCode = true; break; } } r = "joystick" + sJoyCode + " button " + sKeyCode; if (invalidCode) { r = ""; } return(r); }
void Act(XboxButton btn) { if(!_hasEnded) { /*if(_charge >= 10 || _warpAble) { if(btn == XboxButton.buttonA) { //_warpAble = false; _color = PlayerColor.Grass; onColorChange(PlayerColor.Grass); } else if(btn == XboxButton.buttonB) { //_warpAble = false; _color = PlayerColor.Fire; onColorChange(PlayerColor.Fire); } else if(btn == XboxButton.buttonX) { //_warpAble = false; _color = PlayerColor.Water; onColorChange(PlayerColor.Water); } }*/ if(btn == XboxButton.buttonA && _currentTile._type == TileType.Empty && _charge >= 10) { StartCoroutine(_currentTile.Stomped((TileType)_color, true)); //Chain de elemento diferente, vai aumentando o multiplicador int mul = 1; for(int i = 0; i < _currentTile._siblings.Length; i++) { if(_currentTile._siblings[i] != null && _currentTile._siblings[i]._type == TileType.Empty) mul++; } _score += _charge * mul; if(onScoreChange != null) onScoreChange(_input._joyNumber, _score, mul, _charge); //Volta a ser neutro _charge = 0; psys[(int)(_color-1) * 5 ].enableEmission = false; psys[(int)(_color-1) * 5 + 1].enableEmission = false; psys[(int)(_color-1) * 5 + 2].enableEmission = false; psys[(int)(_color-1) * 5 + 3].playOnAwake = true; psys[(int)(_color-1) * 5 + 3].enableEmission = true; psys[(int)(_color-1) * 5 + 4].playOnAwake = true; psys[(int)(_color-1) * 5 + 4].enableEmission = true; _color = PlayerColor.None; onColorChange(_color); //Air Move psys[15].enableEmission = true; } } else { if(btn == XboxButton.buttonA) { Application.LoadLevel("gameplay"); } else if(btn == XboxButton.buttonB) { Application.LoadLevel("mainmenu"); } } }
/// <summary> /// Adds the given buttons to the list of buttons that are blinking /// </summary> /// <param name="buttons"></param> public void AddBlink(XboxButton buttons) { Blink(buttons | _buttonsToBlink); }
/// <summary> /// removes the given buttons from the list of buttons that are blinking /// </summary> /// <param name="buttons"></param> public void RemoveBlink(XboxButton buttons) { Blink(_buttonsToBlink & ~buttons); }
/// <summary> /// hides the given buttons /// </summary> /// <param name="button"></param> public void Hide(XboxButton button) { SetVisibility(button, false); }
/// <summary> /// makes the given buttons visible /// </summary> /// <param name="button"></param> public void Show(XboxButton button) { SetVisibility(button, true); }
public static void SimulateInput(XboxButton button) { _buttons[button] = 1; _instance.StartCoroutine(ResetInput(button)); }
public VirtualButton(XboxController controller, KeyCode key, XboxButton button) { m_ControllerId = controller; m_Key = key; m_Button = button; }
/// <summary> Returns <c>true</c> at the frame the specified button is released by a specified controller. </summary> /// <param name='button'> Identifier for the Xbox button to be tested. </param> /// <param name='controllerNumber'> An identifier for the specific controller on which to test the button. </param> public static bool GetButtonUp(XboxButton button, int controllerNumber) { if(!IsControllerNumberValid(controllerNumber)) return false; string btnCode = DetermineButtonCode(button, controllerNumber); if(Input.GetKeyUp(btnCode)) { return true; } return false; }
public VirtualButton(XboxController controller, XboxButton button, AxisToButton axis) { m_ControllerId = controller; m_Button = button; m_Axis = axis; }
public bool buttonUp(XboxGamePad xgp, XboxButton xb) { Console.WriteLine("buttonUp({0}, {1})", xgp, xb); return(false); }
public static bool GetGamepadButtonHeld(int index, XboxButton btn) { return(GetGamepadButtonHeld(GetState(index), btn)); }
public Dodge(s_Player p, XboxButton kc) : base(p, kc) { }
/// <summary> /// Returns <c>true</c> at the frame the specified button is released by a specified controller. /// </summary> /// <param name='button'> /// Identifier for the Xbox button to be tested. /// </param> /// <param name='controller'> /// An identifier for the specific controller on which to test the button. /// </param> public static bool GetButtonUp(XboxButton button, XboxController controller) { if (button.IsDPad()) return GetDPadUp(button.ToDPad(), controller); if (controller == XboxController.All) return GetButtonUp(button); int controllerNumber = (int)controller; if(OnWindowsNative()) { if(Time.frameCount < 2) { return false; } if(!XInputStillInCurrFrame()) { XInputUpdateAllStates(); } GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) { return true; } } else { string btnCode = DetermineButtonCode(button, controllerNumber); if(Input.GetKeyUp(btnCode)) { return true; } } return false; }
public static void SimulateInput(XboxButton button, float value) { _buttons[button] = value; }
/// <summary> Returns <c>true</c> at the frame the specified button is released by any controller. </summary> /// <param name='button'> Identifier for the Xbox button to be tested. </param> public static bool GetButtonUp(XboxButton button) { string btnCode = DetermineButtonCode(button, 0); if(Input.GetKeyUp(btnCode)) { return true; } return false; }
/// <summary> /// Resets the ButtonState of the button in the current button dictionary /// </summary> /// <param name="button">The button to reset</param> public void ResetButton(XboxButton button) { currentButtonDict[button] = ButtonState.Released; }
private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) { string r = ""; string sJoyCode = ""; string sKeyCode = ""; bool invalidCode = false; if(ctrlrNum == 0) { sJoyCode = ""; } else { sJoyCode = " " + ctrlrNum.ToString(); } if(OnMac()) { switch(btn) { case XboxButton.A: sKeyCode = "16"; break; case XboxButton.B: sKeyCode = "17"; break; case XboxButton.X: sKeyCode = "18"; break; case XboxButton.Y: sKeyCode = "19"; break; case XboxButton.Start: sKeyCode = "9"; break; case XboxButton.Back: sKeyCode = "10"; break; case XboxButton.LeftStick: sKeyCode = "11"; break; case XboxButton.RightStick: sKeyCode = "12"; break; case XboxButton.LeftBumper: sKeyCode = "13"; break; case XboxButton.RightBumper: sKeyCode = "14"; break; default: invalidCode = true; break; } } else if (OnLinux()) { switch(btn) { case XboxButton.A: sKeyCode = "0"; break; case XboxButton.B: sKeyCode = "1"; break; case XboxButton.X: sKeyCode = "2"; break; case XboxButton.Y: sKeyCode = "3"; break; case XboxButton.Start: sKeyCode = "7"; break; case XboxButton.Back: sKeyCode = "6"; break; case XboxButton.LeftStick: sKeyCode = "9"; break; case XboxButton.RightStick: sKeyCode = "10"; break; case XboxButton.LeftBumper: sKeyCode = "4"; break; case XboxButton.RightBumper: sKeyCode = "5"; break; default: invalidCode = true; break; } } else { switch(btn) { case XboxButton.A: sKeyCode = "0"; break; case XboxButton.B: sKeyCode = "1"; break; case XboxButton.X: sKeyCode = "2"; break; case XboxButton.Y: sKeyCode = "3"; break; case XboxButton.Start: sKeyCode = "7"; break; case XboxButton.Back: sKeyCode = "6"; break; case XboxButton.LeftStick: sKeyCode = "8"; break; case XboxButton.RightStick: sKeyCode = "9"; break; case XboxButton.LeftBumper: sKeyCode = "4"; break; case XboxButton.RightBumper: sKeyCode = "5"; break; default: invalidCode = true; break; } } r = "joystick" + sJoyCode + " button " + sKeyCode; if(invalidCode) { r = ""; } return r; }
/// <summary> Returns <c>true</c> at the frame the specified button is released by any controller. </summary> /// <param name='button'> Identifier for the Xbox button to be tested. </param> public static bool GetButtonUp(XboxButton button) { if(OnWindowsNative()) { if(Time.frameCount < 2) { return false; } if(!XInputStillInCurrFrame()) { XInputUpdateAllStates(); //XInputUpdateSingleState(); } GamePadState ctrlrState = XInputGetSingleState(); GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) { return true; } } else { string btnCode = DetermineButtonCode(button, 0); if(Input.GetKeyUp(btnCode)) { return true; } } return false; }
/// <summary> Returns <c>true</c> if the specified button is held down by a specified controller. </summary> /// <param name='button'> Identifier for the Xbox button to be tested. </param> /// <param name='controllerNumber'> An identifier for the specific controller on which to test the button. An int between 1 and 4. </param> public static bool GetButton(XboxButton button, int controllerNumber) { if(!IsControllerNumberValid(controllerNumber)) return false; if(OnWindowsNative()) { if(!XInputStillInCurrFrame()) { XInputUpdateAllStates(); //XInputUpdatePaticularState(controllerNumber); } GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) { return true; } } else { string btnCode = DetermineButtonCode(button, controllerNumber); if(Input.GetKey(btnCode)) { return true; } } return false; }
public CommandA(s_Player p, XboxButton kc) { myPlayer = p; xbb = kc; }
private void Update() { //Tether movement float axisY = XCI.GetAxis(XboxAxis.LeftStickY, controller); //Store the direction and magnitude of the left joystick Y axis tether.currentLength += tether.changeSpeed * -axisY * Time.deltaTime; //Move tether length up/down based on this //Animation //if the control stick is pushed 40% of the way upwards if (axisY >= 0.4) { //sets the animation state to moving forward characterAnim.SetBool("MovingForward", true); characterAnim.SetBool("MovingBackward", false); } //if the control stick is pushed 40% of the way downwards else if (axisY <= -0.4) { //sets the animation state to moving backwards characterAnim.SetBool("MovingForward", false); characterAnim.SetBool("MovingBackward", true); } //if neither else { //sets the animation state to idle characterAnim.SetBool("MovingForward", false); characterAnim.SetBool("MovingBackward", false); } //Sideways movement if (tether.Distance() >= (tether.currentLength * 0.95f)) //As long as the skier is close to the arc of the tether, { float axisX = XCI.GetAxis(XboxAxis.LeftStickX, controller); //Store the direction and magnitude of the left joystick X axis tether.ApplyForce(new Vector3(movingForce * axisX, 0, 0)); //Apply an instantaneous sideways force //Animation //if the control stick is pushed 40% of the way to the right if (axisX >= 0.4) { //sets the animation state to moving right characterAnim.SetBool("MovingLeft", false); characterAnim.SetBool("MovingRight", true); } //if the control stick is pushed 40% of the way to the left else if (axisX <= -0.4) { //sets the animation state to moving left characterAnim.SetBool("MovingRight", false); characterAnim.SetBool("MovingLeft", true); } //if neither else { //sets the animation state to idle characterAnim.SetBool("MovingRight", false); characterAnim.SetBool("MovingLeft", false); } } //Easter egg if (!m_eggUnlocked) { for (XboxButton i = 0; i <= XboxButton.Y; ++i) { if (XCI.GetButtonDown(i)) { if (i == m_sequence[m_progress]) { ++m_progress; if (m_sequence[m_progress] == 0) { m_eggUnlocked = true; } } else { m_progress = 0; } } } } else { if (XCI.GetButtonDown(XboxButton.A)) { tether.ApplyForce(new Vector3(0, 500, 0)); } } //Wipeout if (m_isAlive == false) { //Make them sink Vector3 newPos = transform.position; newPos.y -= Time.deltaTime; transform.position = newPos; //Make their tether fade RopeLine renderedTether = GetComponentInChildren <RopeLine>(); if (renderedTether != null) { renderedTether.Fade(1); } } bonkResolved = false; }
// Update is called once per frame void Update() { transform.position = m_parent.position + m_offset; m_fireTimer -= Time.deltaTime; if (m_playerNumber != -1) { XboxController controller = XboxController.All; XboxAxis stickX = XboxAxis.LeftStickX; XboxAxis stickY = XboxAxis.LeftStickY; XboxButton activate = XboxButton.LeftBumper; switch (m_playerNumber) { case 1: controller = XboxController.First; stickX = XboxAxis.LeftStickX; stickY = XboxAxis.LeftStickY; activate = XboxButton.LeftBumper; break; case 2: controller = XboxController.First; stickX = XboxAxis.RightStickX; stickY = XboxAxis.RightStickY; activate = XboxButton.RightBumper; break; case 3: controller = XboxController.Second; stickX = XboxAxis.LeftStickX; stickY = XboxAxis.LeftStickY; activate = XboxButton.LeftBumper; break; case 4: controller = XboxController.Second; stickX = XboxAxis.RightStickX; stickY = XboxAxis.RightStickY; activate = XboxButton.RightBumper; break; } //Quaternion rotation = Quaternion.Euler(0, XCI.GetAxisRaw(stickX, controller) * m_rotationSpeed, 0); //transform.rotation *= rotation; Vector3 facing = new Vector3(XCI.GetAxisRaw(stickX, controller), 0, XCI.GetAxisRaw(stickY, controller)); if (facing.sqrMagnitude != 0) { transform.forward = facing; } if (XCI.GetButton(activate, controller)) { if (m_fireTimer <= 0) { GameObject bullet = Instantiate(m_bulletPrefab, transform.position + transform.forward * 2, transform.rotation); bullet.GetComponent <Rigidbody>().velocity = transform.forward * m_bulletSpeed; bullet.GetComponent <Bullet>().m_team = m_team; m_fireTimer = m_fireRate; } } } }