mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 21:08:28 +00:00
Sending input to server
This commit is contained in:
parent
2d9f998a20
commit
2e623e71f1
1 changed files with 15 additions and 8 deletions
|
@ -49,10 +49,23 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
|
||||
// local ped is occupying driver seat
|
||||
|
||||
this.ResetInput();
|
||||
if (!GameManager.CanPlayerReadInput())
|
||||
this.ResetInput();
|
||||
else
|
||||
this.ReadInput();
|
||||
|
||||
if (!GameManager.CanPlayerReadInput()) return;
|
||||
PedSync.Local.SendVehicleInput(m_vehicle.Accelerator, m_vehicle.Steering, m_vehicle.Braking);
|
||||
}
|
||||
|
||||
void ResetInput()
|
||||
{
|
||||
m_vehicle.Accelerator = 0;
|
||||
m_vehicle.Steering = 0;
|
||||
m_vehicle.Braking = 0;
|
||||
}
|
||||
|
||||
void ReadInput()
|
||||
{
|
||||
var accel = Input.GetAxis("Vertical");
|
||||
var brake = Input.GetButton("Brake") ? 1.0f : 0.0f;
|
||||
var speed = Vector3.Dot(m_vehicle.Velocity, m_vehicle.transform.forward);
|
||||
|
@ -68,11 +81,5 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
m_vehicle.Braking = brake;
|
||||
}
|
||||
|
||||
void ResetInput()
|
||||
{
|
||||
m_vehicle.Accelerator = 0;
|
||||
m_vehicle.Steering = 0;
|
||||
m_vehicle.Braking = 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue