Skip to content

Commit

Permalink
Networking, Base input and Xbox Input added
Browse files Browse the repository at this point in the history
  • Loading branch information
snlpatel001213 committed Nov 24, 2021
1 parent dbcff47 commit 9a332ff
Show file tree
Hide file tree
Showing 34 changed files with 3,519 additions and 511 deletions.
8 changes: 8 additions & 0 deletions Assets/AirplanePhysics/Art/Logos.meta

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions Assets/AirplanePhysics/Art/Logos/AirControl_Logo_Medium.png.meta

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions Assets/AirplanePhysics/Art/Logos/AirControl_Logo_Small.png.meta

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

8 changes: 8 additions & 0 deletions Assets/AirplanePhysics/Code/Scripts/Input.meta

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

79 changes: 79 additions & 0 deletions Assets/AirplanePhysics/Code/Scripts/Input/AC_BaseAirplane_Input.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AirControl
{
public class AC_BaseAirplane_Input : MonoBehaviour
{
#region Variable

protected float pitch = 0f;
protected float roll = 0f;
protected float yaw = 0f;
protected float throttle = 0f;
protected float brake = 0f;
public int maxFlapIncrements=2; // maximum increment allowed to flaps
protected int flaps = 0;
#endregion

#region Properties
public float Pitch{
get{return pitch;}
}
public float Roll{
get{return roll;}
}
public float Yaw{
get{return yaw;}
}
public float Throttle{
get{return throttle;}
}
public int Flaps{
get{return flaps;}
}
public float Brake{
get{return brake;}
}
#endregion


#region Builtin Methods
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
HandleInput();
}
#endregion

#region Custom Methods
protected virtual void HandleInput(){
// Process pitch, roll, yaw and throttle
pitch = Input.GetAxis("Vertical");
roll = Input.GetAxis("Horizontal");
yaw = Input.GetAxis("yaw");
throttle = Input.GetAxis("throttle");
// Process brakes bool
brake = Input.GetKey(KeyCode.Space)?1f:0f;
// Process flaps
// get GetKeyDown is used because it fires only once when key pressed. GetKey constantly fire events
if(Input.GetKeyDown(KeyCode.F)){
flaps+=1;
}
if(Input.GetKeyDown(KeyCode.G)){
flaps-=1;
}
flaps = Mathf.Clamp(flaps, 0,maxFlapIncrements);

}
#endregion
}


}

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

56 changes: 56 additions & 0 deletions Assets/AirplanePhysics/Code/Scripts/Input/AC_XboxAirplane_Input.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AirControl
{
public class AC_XboxAirplane_Input : AC_BaseAirplane_Input
{
#region Variable

#endregion

#region Builtin Methods
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}
#endregion

#region Custom Methods
/// make sure you update input settings in Unity
/// Then Only Xbox will work properly
/// Refer to resources for setup
// 1. https://answers.unity.com/questions/1350081/xbox-one-controller-mapping-solved.html
// 2. https://www.udemy.com/course/intro-to-airplane-physics-in-unity-3d/learn/lecture/10348654#questions
protected override void HandleInput()
{
// Process pitch, roll, yaw and throttle
pitch = Input.GetAxis("Vertical");
roll = Input.GetAxis("Horizontal");
yaw = Input.GetAxis("X_RH_Stick");
throttle = Input.GetAxis("X_RV_Stick");
// Process brakes bool
brake = Input.GetAxis("Fire1");
// Process flaps
// get GetKeyDown is used because it fires only once when key pressed. GetKey constantly fire events
if(Input.GetButtonDown("X_R_Bumper")){
flaps+=1;
}
if(Input.GetButtonDown("X_L_Bumper")){
flaps-=1;
}
flaps = Mathf.Clamp(flaps, 0,maxFlapIncrements);

}
#endregion

}

}

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

8 changes: 8 additions & 0 deletions Assets/AirplanePhysics/Code/Scripts/Input/Editor.meta

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

Loading

0 comments on commit 9a332ff

Please sign in to comment.