Skip to content

Commit

Permalink
feature: flaps keyboard control #66
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka-L committed Sep 10, 2023
1 parent 8c1e23a commit 64797d5
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 64797d5

Please # to comment.