Skip to content

Commit

Permalink
Merge pull request #101 from Misaka-L/main
Browse files Browse the repository at this point in the history
feature: flaps keyboard control #66
  • Loading branch information
Misaka-L authored Sep 10, 2023
2 parents 8c1e23a + 64797d5 commit 1953b1a
Show file tree
Hide file tree
Showing 10 changed files with 883 additions and 280 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using EsnyaSFAddons.DFUNC;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

namespace A320VAU.SFEXT {
public class SFEXT_a320_AdvancedFlapsKeyboardControl : UdonSharpBehaviour {
public DFUNC_AdvancedFlaps advancedFlaps;

public KeyCode flapsUpKey = KeyCode.Alpha1;
public KeyCode flapsDownKey = KeyCode.Alpha2;

private bool _isKeyPress;

private void LateUpdate() {
if (Input.GetKey(flapsUpKey)) {
if (_isKeyPress) return;

var targetFlapDetentIndex = advancedFlaps.targetDetentIndex - 1;
if (targetFlapDetentIndex < advancedFlaps.detents.Length && targetFlapDetentIndex >= 0)
advancedFlaps.targetAngle = advancedFlaps.detents[targetFlapDetentIndex];

_isKeyPress = true;
return;
}

if (Input.GetKey(flapsDownKey)) {
if (_isKeyPress) return;

var targetFlapDetentIndex = advancedFlaps.targetDetentIndex + 1;
if (targetFlapDetentIndex < advancedFlaps.detents.Length && targetFlapDetentIndex >= 0)
advancedFlaps.targetAngle = advancedFlaps.detents[targetFlapDetentIndex];

_isKeyPress = true;
return;
}

_isKeyPress = false;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1953b1a

Please # to comment.