Skip to content
Snippets Groups Projects
Commit 75d30e1c authored by Clinton Galbraith's avatar Clinton Galbraith
Browse files

Merge branch 'develop' into 'feature_shooting'

Develop

See merge request !6
parents 35192060 b2d45dc8
No related branches found
No related tags found
3 merge requests!8Develop,!7Feature shooting,!6Develop
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GamepadInput : MonoBehaviour {
[SerializeField]
float Deadzone;
float maxComparable;
[SerializeField]
PlayerBehavior myPlayer;
// Use this for initialization
void Start () {
maxComparable = 1 - Deadzone;
}
// Update is called once per frame
void Update () {
float leftX = Input.GetAxis("Left Horizontal");
float leftY = Input.GetAxis("Left Vertical");
/* Ratio of joystick amount over the deadzone */
myPlayer.MoveHorizontal(leftX);
myPlayer.MoveVertical(leftY);
if (Input.GetButton("Xbox B"))
myPlayer.Brake();
}
}
fileFormatVersion: 2
guid: 9ae2cb071c24c534ca4556fd157e062a
timeCreated: 1506465138
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -17,10 +17,10 @@ public class InputManagerScript : MonoBehaviour { ...@@ -17,10 +17,10 @@ public class InputManagerScript : MonoBehaviour {
playerOneBehavior = playerOne.GetComponent<PlayerBehavior>(); playerOneBehavior = playerOne.GetComponent<PlayerBehavior>();
playerTwoBehavior = playerTwo.GetComponent<PlayerBehavior>(); playerTwoBehavior = playerTwo.GetComponent<PlayerBehavior>();
} }
// Update is called once per frame
void Update () {
private void KeyboardInput()
{
/** /**
* Player One Movement Controls * Player One Movement Controls
*/ */
...@@ -71,4 +71,21 @@ public class InputManagerScript : MonoBehaviour { ...@@ -71,4 +71,21 @@ public class InputManagerScript : MonoBehaviour {
playerTwoBehavior.Brake(); playerTwoBehavior.Brake();
} }
} }
public void JoypadOneInput()
{
playerOneBehavior.MoveHorizontal(Input.GetAxis("Left Horizontal"));
playerOneBehavior.MoveVertical(Input.GetAxis("Left Vertical"));
if (Input.GetButton("Xbox B"))
playerOneBehavior.Brake();
}
// Update is called once per frame
void Update () {
KeyboardInput();
JoypadOneInput();
}
} }
...@@ -40,22 +40,31 @@ public class PlayerBehavior : MonoBehaviour { ...@@ -40,22 +40,31 @@ public class PlayerBehavior : MonoBehaviour {
{ {
frameMovement.x -= acceleration; frameMovement.x -= acceleration;
} }
public void MoveRight() public void MoveRight()
{ {
frameMovement.x += acceleration; frameMovement.x += acceleration;
} }
public void MoveUp() public void MoveUp()
{ {
frameMovement.y += acceleration; frameMovement.y += acceleration;
} }
public void MoveDown() public void MoveDown()
{ {
frameMovement.y -= acceleration; frameMovement.y -= acceleration;
} }
public void MoveHorizontal(float f)
{
if(Mathf.Abs(f) <= 1)
frameMovement.x += f;
}
public void MoveVertical(float f)
{
if (Mathf.Abs(f) <= 1)
frameMovement.y += f;
}
/** /**
* Scale the player's velocity down, if brakeFraction is < zero * Scale the player's velocity down, if brakeFraction is < zero
*/ */
......
...@@ -6,7 +6,7 @@ InputManager: ...@@ -6,7 +6,7 @@ InputManager:
serializedVersion: 2 serializedVersion: 2
m_Axes: m_Axes:
- serializedVersion: 3 - serializedVersion: 3
m_Name: Horizontal m_Name: Left Horizontal
descriptiveName: descriptiveName:
descriptiveNegativeName: descriptiveNegativeName:
negativeButton: left negativeButton: left
...@@ -14,15 +14,15 @@ InputManager: ...@@ -14,15 +14,15 @@ InputManager:
altNegativeButton: a altNegativeButton: a
altPositiveButton: d altPositiveButton: d
gravity: 3 gravity: 3
dead: 0.001 dead: 0.3
sensitivity: 3 sensitivity: 3
snap: 1 snap: 1
invert: 0 invert: 0
type: 0 type: 2
axis: 0 axis: 0
joyNum: 0 joyNum: 1
- serializedVersion: 3 - serializedVersion: 3
m_Name: Vertical m_Name: Left Vertical
descriptiveName: descriptiveName:
descriptiveNegativeName: descriptiveNegativeName:
negativeButton: down negativeButton: down
...@@ -30,266 +30,26 @@ InputManager: ...@@ -30,266 +30,26 @@ InputManager:
altNegativeButton: s altNegativeButton: s
altPositiveButton: w altPositiveButton: w
gravity: 3 gravity: 3
dead: 0.001 dead: 0.3
sensitivity: 3 sensitivity: 3
snap: 1 snap: 1
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left ctrl
altNegativeButton:
altPositiveButton: mouse 0
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
altNegativeButton:
altPositiveButton: mouse 1
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire3
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left shift
altNegativeButton:
altPositiveButton: mouse 2
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Jump
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: space
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse X
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse Y
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 1
joyNum: 0
- serializedVersion: 3
m_Name: Mouse ScrollWheel
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 2
joyNum: 0
- serializedVersion: 3
m_Name: Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0.19
sensitivity: 1
snap: 0
invert: 0
type: 2
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0.19
sensitivity: 1
snap: 0
invert: 1 invert: 1
type: 2 type: 2
axis: 1 axis: 1
joyNum: 0 joyNum: 1
- serializedVersion: 3
m_Name: Fire1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 0
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 1
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire3
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 2
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3 - serializedVersion: 3
m_Name: Jump m_Name: Xbox B
descriptiveName: descriptiveName:
descriptiveNegativeName: descriptiveNegativeName:
negativeButton: negativeButton:
positiveButton: joystick button 3 positiveButton: joystick 1 button 1
altNegativeButton: altNegativeButton:
altPositiveButton: altPositiveButton:
gravity: 1000 gravity: 1000
dead: 0.001 dead: 0
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: return
altNegativeButton:
altPositiveButton: joystick button 0
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: enter
altNegativeButton:
altPositiveButton: space
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Cancel
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: escape
altNegativeButton:
altPositiveButton: joystick button 1
gravity: 1000
dead: 0.001
sensitivity: 1000 sensitivity: 1000
snap: 0 snap: 1
invert: 0 invert: 0
type: 0 type: 0
axis: 0 axis: 0
joyNum: 0 joyNum: 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment