-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Several API changes. Version 2.x starts
- Loading branch information
Vatsal Ambastha
committed
Apr 18, 2020
1 parent
0373497
commit e6752cb
Showing
27 changed files
with
341 additions
and
3,841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
Assets/Adrenak.Tork/Editor/CenterOfMassAssignerDebug.cs.meta
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Adrenak.Tork { | ||
public interface IVehicleDriver { | ||
VehicleInput GetInput(); | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
Assets/Adrenak.Tork/Runtime/Input/KeyboardVehicleDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
|
||
namespace Adrenak.Tork{ | ||
public class KeyboardVehicleDriver : IVehicleDriver { | ||
public const string k_SteeringAxisName = "Horizontal"; | ||
public const string k_AccelerateAxisName = "Vertical"; | ||
public const string k_BrakeAxisName = "Jump"; | ||
|
||
public VehicleInput GetInput() { | ||
return new VehicleInput { | ||
acceleration = Input.GetAxis(k_AccelerateAxisName), | ||
steering = Input.GetAxis(k_SteeringAxisName), | ||
brake = Input.GetAxis(k_BrakeAxisName) | ||
}; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
using UnityEngine; | ||
|
||
namespace Adrenak.Tork { | ||
public class Vehicle : MonoBehaviour { | ||
[SerializeField] VehicleDriver m_Player; | ||
public class Vehicle : MonoBehaviour { | ||
readonly IVehicleDriver defaultDriver = new KeyboardVehicleDriver(); | ||
IVehicleDriver driver; | ||
public IVehicleDriver Driver { | ||
get { return driver = driver ?? defaultDriver; } | ||
set { driver = value ?? defaultDriver; } | ||
} | ||
|
||
public Steering m_Steering; | ||
public Motor m_Motor; | ||
public Brakes m_Brake; | ||
[SerializeField] Steering steering; | ||
public Steering Steer { get { return steering; } } | ||
|
||
public void SetPlayer(VehicleDriver player) { | ||
m_Player = player; | ||
} | ||
[SerializeField] Motor motor; | ||
public Motor Motor { get { return motor; } } | ||
|
||
void Update() { | ||
if (m_Player == null) return; | ||
[SerializeField] Brakes brake; | ||
public Brakes Brake { get { return brake; } } | ||
|
||
var input = m_Player.GetInput(); | ||
void Update() { | ||
var input = Driver.GetInput(); | ||
|
||
m_Steering.value = input.steering; | ||
m_Motor.value = input.acceleration; | ||
m_Brake.value = input.brake; | ||
} | ||
} | ||
steering.value = input.steering; | ||
motor.value = input.acceleration; | ||
brake.value = input.brake; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.