Commit da7cf2a1 authored by Corantin Hoffert's avatar Corantin Hoffert 💥
Browse files

Merge branch 'bugfix/physics' into 'develop'

General fixes

See merge request fauchezlegouic/projet-integrateur!405
parents f2728e74 ac7e8683
......@@ -686,6 +686,7 @@ MonoBehaviour:
shield: {fileID: 1530598418984531185}
customizableMaterial: {fileID: 2100000, guid: 92ed74da84a7e664d8d294f6f8bb0045,
type: 2}
meshRenderer: {fileID: 3429886832395392221}
--- !u!114 &1898532462439949835
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -961,6 +961,7 @@ MonoBehaviour:
shield: {fileID: 2933040619362178280}
customizableMaterial: {fileID: 2100000, guid: 5e5982c6530abd94daa99687d0f28388,
type: 2}
meshRenderer: {fileID: 7103723555510876112}
--- !u!114 &3058658948622271665
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -961,6 +961,7 @@ MonoBehaviour:
shield: {fileID: 8206736549006792958}
customizableMaterial: {fileID: 2100000, guid: a64fc39d12635594ab512958d365c598,
type: 2}
meshRenderer: {fileID: 758259270122560029}
--- !u!114 &3350980876703986545
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -917,6 +917,7 @@ MonoBehaviour:
shield: {fileID: 2245993262976378628}
customizableMaterial: {fileID: 2100000, guid: f350250de1b11da4f8f6ef6986fbfd9d,
type: 2}
meshRenderer: {fileID: 3675183384369060154}
--- !u!114 &247611631114641570
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -88,7 +88,7 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- Color_F5EC01B6: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 0.2}
- Color_F5EC01B6: {r: 0.1254902, g: 0.11372549, b: 0.11372549, a: 0.2}
- _BaseColor: {r: 0.020249316, g: 0, b: 0.06680677, a: 1}
- _Color: {r: 0.020249316, g: 0, b: 0.06680677, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
......
......@@ -34,7 +34,7 @@ Material:
serializedVersion: 3
m_TexEnvs:
- Texture2D_23FC72E3:
m_Texture: {fileID: 2800000, guid: 4eda357a78c79964296c73e2072dcf1b, type: 3}
m_Texture: {fileID: 2800000, guid: 463533940a2645f42aa93444deab6650, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseMap:
......@@ -88,7 +88,7 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- Color_F5EC01B6: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 0.2}
- Color_F5EC01B6: {r: 0.5568628, g: 0.44705883, b: 0.27450982, a: 0.2}
- _BaseColor: {r: 0.55834055, g: 0.44520116, b: 0.27467734, a: 1}
- _Color: {r: 0.55834055, g: 0.44520116, b: 0.27467734, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
......
......@@ -88,7 +88,7 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- Color_F5EC01B6: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 0.2}
- Color_F5EC01B6: {r: 0.90588236, g: 0.63529414, b: 0, a: 0.2}
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
......
......@@ -21,7 +21,7 @@ Material:
serializedVersion: 3
m_TexEnvs:
- Texture2D_23FC72E3:
m_Texture: {fileID: 2800000, guid: c772402570e06234a9c95fe41f41b62e, type: 3}
m_Texture: {fileID: 2800000, guid: b55fcdfb9c85d6c45be8ea2bc59a88d7, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseMap:
......
......@@ -4499,11 +4499,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5fddbe71ec5028446bfd82db70f8c4fa, type: 3}
m_Name:
m_EditorClassIdentifier:
hostname: sv.wreckingbrawl.tk
hostname: 127.0.0.1
serverPort: 6667
accountConnection: {fileID: 0}
accountCreation: {fileID: 0}
loadingScreen: {fileID: 0}
vehicleType: 0
playerPrefab: {fileID: 8015372863101394761, guid: c4116d132fe3a0440afdeb8e0f465bdf,
type: 3}
......@@ -5257,6 +5254,12 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 587f31e5286cdc24abca9eda7fab8c27, type: 3}
--- !u!4 &8070572500340193279 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5917775871526648733, guid: 587f31e5286cdc24abca9eda7fab8c27,
type: 3}
m_PrefabInstance: {fileID: 2459043602570480738}
m_PrefabAsset: {fileID: 0}
--- !u!114 &8070572500340193278 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5917775871526648732, guid: 587f31e5286cdc24abca9eda7fab8c27,
......@@ -5269,12 +5272,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ad5f4cba61df8d549a67de45bfe63b03, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &8070572500340193279 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5917775871526648733, guid: 587f31e5286cdc24abca9eda7fab8c27,
type: 3}
m_PrefabInstance: {fileID: 2459043602570480738}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &2946051463885123309
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -5481,12 +5478,12 @@ PrefabInstance:
type: 3}
propertyPath: m_Navigation.m_SelectOnDown
value:
objectReference: {fileID: 0}
objectReference: {fileID: 8800430390283762311}
- target: {fileID: 1190738033517441316, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_Navigation.m_SelectOnRight
value:
objectReference: {fileID: 0}
objectReference: {fileID: 8800430391131596151}
- target: {fileID: 1190738033774818272, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_AnchorMax.y
......@@ -5647,10 +5644,15 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1190738034096253178, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 116.62891
objectReference: {fileID: 0}
- target: {fileID: 1190738034474488202, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -58.499878
value: -58.5
objectReference: {fileID: 0}
- target: {fileID: 1586838076710797820, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
......@@ -5682,11 +5684,16 @@ PrefabInstance:
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2345752362351342417, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -238.02979
objectReference: {fileID: 0}
- target: {fileID: 2555442745562988373, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_Navigation.m_SelectOnDown
value:
objectReference: {fileID: 0}
objectReference: {fileID: 4063412193050157001}
- target: {fileID: 3128959080947932508, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_AnchoredPosition.y
......@@ -5696,7 +5703,7 @@ PrefabInstance:
type: 3}
propertyPath: m_Navigation.m_SelectOnDown
value:
objectReference: {fileID: 0}
objectReference: {fileID: 8800430391131596151}
- target: {fileID: 5778445946264503145, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
propertyPath: m_AnchorMax.y
......@@ -5764,12 +5771,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e755bb3134d673445bb5237bff084edd, type: 3}
--- !u!224 &4063412192865519827 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1190738033869710910, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
m_PrefabInstance: {fileID: 2946051463885123309}
m_PrefabAsset: {fileID: 0}
--- !u!114 &4063412192865519830 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1190738033869710907, guid: e755bb3134d673445bb5237bff084edd,
......@@ -5782,6 +5783,48 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 651452e7a0d4fd84090e3339adae14ad, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &4063412193050157001 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1190738033517441316, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
m_PrefabInstance: {fileID: 2946051463885123309}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &8800430390283762311 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5963631096151020650, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
m_PrefabInstance: {fileID: 2946051463885123309}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &8800430391131596151 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5963631097586060186, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
m_PrefabInstance: {fileID: 2946051463885123309}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!224 &4063412192865519827 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1190738033869710910, guid: e755bb3134d673445bb5237bff084edd,
type: 3}
m_PrefabInstance: {fileID: 2946051463885123309}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &4203375352894382719
PrefabInstance:
m_ObjectHideFlags: 0
......
......@@ -2712,9 +2712,9 @@ RectTransform:
m_Father: {fileID: 3061060625952290675}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -287}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 253}
m_SizeDelta: {x: 493.34174, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3061060625873373228
......
......@@ -2341,9 +2341,9 @@ RectTransform:
m_Father: {fileID: 4300799675837987635}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -287}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 253}
m_SizeDelta: {x: 493.34174, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4300799675910063212
......
......@@ -636,7 +636,7 @@ PrefabInstance:
- target: {fileID: 7882731905481241667, guid: 3c3a4672706374b45a0813bf3019f627,
type: 3}
propertyPath: insecureMode
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7882731905481241667, guid: 3c3a4672706374b45a0813bf3019f627,
type: 3}
......@@ -648,6 +648,11 @@ PrefabInstance:
propertyPath: accountCreation
value:
objectReference: {fileID: 828838654}
- target: {fileID: 7882731905481241667, guid: 3c3a4672706374b45a0813bf3019f627,
type: 3}
propertyPath: updatesPerSecond
value: 30
objectReference: {fileID: 0}
- target: {fileID: 7882731905481241667, guid: 3c3a4672706374b45a0813bf3019f627,
type: 3}
propertyPath: accountConnection
......
......@@ -57,7 +57,7 @@ public class CollisionManager : MonoBehaviour
private void FixedUpdate()
{
_speedBeforeImpact = _vehicle.GetSpeed();
_speedBeforeImpact = _vehicle._prevSpeed == -1 ? _vehicle._currentSpeed : _vehicle._prevSpeed;
}
/**
......
......@@ -130,8 +130,15 @@ public class GarageManager : SettingsManager<GarageManager>
public static void ApplyCustomization(VehicleBase vehicle, int carType, int colorIndex, int decalIndex)
{
ApplyColor(ref vehicle.model.customizableMaterial, colorIndex);
ApplyDecal(ref vehicle.model.customizableMaterial, carType, decalIndex);
var mats = vehicle.model.meshRenderer.materials;
var matIndex = mats.ToList().FindIndex(x => x.name.Contains(vehicle.model.customizableMaterial.name));
if (matIndex == -1 || matIndex >= mats.Length) return;
var mat = mats[matIndex];
vehicle.model.meshRenderer.materials[matIndex] = Instantiate(mat);
ApplyColor(ref vehicle.model.meshRenderer.materials[matIndex], colorIndex);
ApplyDecal(ref vehicle.model.meshRenderer.materials[matIndex], decalIndex, carType);
}
public static int GetActiveColor(int carType)
......
......@@ -75,16 +75,17 @@ public abstract class AbstractLobbyScreen : GameScreen
{
Cursor.visible = true;
playerListUI.addPlayerButton.Button.onClick.AddListener(OnAddPlayerClick);
//playerListUI.OnPlayerRemoved = OnPlayerRemovedFromLobby;
chatButton.onClick.AddListener(() => OpenScreen("LobbyChatPanel", time: 0.2f));
playButton.onToggle = ReadyUp;
ToggleLoadingText(false);
FriendsUIManager.Instance.invitationNotif.Hide(true);
_leader = LobbyGroup.current.LeaderId == -1;
if (!_leader)
FriendsUIManager.Instance.invitationNotif.Hide(true);
if (!_leader)
{
Destroy(changeGamemodeButton.gameObject);
......
......@@ -462,12 +462,12 @@ public class NetworkManager : MonoBehaviour
// Check if the player needs to reset his position
if (_playerSpawned && PositionDifferent(updateInfos[i].position, _player.vehicle.transform.position))
{
_player.UpdateVehicleStats(updateInfos[i]);
_player.UpdateVehicleStats(updateInfos[i], false);
}
}
else
{
player.UpdateVehicleStats(updateInfos[i]);
player.UpdateVehicleStats(updateInfos[i], true);
}
}
}
......
......@@ -56,8 +56,14 @@ public class Player
}
/* Update the player's vehicle from a EntityUpdate */
public void UpdateVehicleStats(EntityUpdate updates)
public void UpdateVehicleStats(EntityUpdate updates, bool isOther)
{
if (!vehicle._hasEffect && isOther)
{
vehicle._rigidbody.velocity = Vector3.zero;
}
vehicle._prevSpeed = vehicle._currentSpeed;
vehicle._currentSpeed = updates.currentSpeed;
vehicle._currentSteering = updates.currentSteering;
vehicle._currentTorque = updates.currentTorque;
......@@ -70,6 +76,8 @@ public class Player
// This may or may not prevent the vehicle from adding up Y velocity
vehicle._rigidbody.AddForce(Vector3.up * Mathf.Pow(Physics.gravity.y, 2));
//GameManager.Instance.RunDelayed(() => vehicle._currentSpeed = updates.currentSpeed, )
}
/* Update the player's EntityUpdate from his vehicle current state */
......
......@@ -35,6 +35,8 @@ public class VehicleBase : MonoBehaviour, IVehicleController
internal CollisionManager _collisionManager; // The collision manager of the vehicle
internal bool _hasEffect = false; // Does the vehicle has any effect currently active?
internal float _prevSpeed = -1;
public AudioSource hornSource;
public float handBrakeInterval = 2f;
......@@ -102,7 +104,8 @@ public class VehicleBase : MonoBehaviour, IVehicleController
internal void Update()
{
_currentSpeed = GetSpeed(); // Update the current speed
if (!(this is VehicleOther))
_currentSpeed = GetSpeed(); // Update the current speed
if (model is null) return;
if (_braking)
......@@ -189,8 +192,8 @@ public class VehicleBase : MonoBehaviour, IVehicleController
}
else if (_isSlowDown)
{
axleInfo.leftWheel.brakeTorque = 10000;
axleInfo.rightWheel.brakeTorque = 10000;
axleInfo.leftWheel.brakeTorque = 6000;
axleInfo.rightWheel.brakeTorque = 6000;
}
else
{
......
......@@ -11,87 +11,5 @@ using UnityEngine;
*/
public class VehicleOther : VehicleBase
{
internal new void FixedUpdate()
{
OnUpdateVehicle();
if (model is null) return;
// Change the steer angle based on the current speed
_rigidbody.velocity = Vector3.zero;
_currentSpeed = 0;
float speedFactor = _currentSpeed / carStats.maxForwardSpeed;
float steerAngle = Mathf.Lerp(carStats.lowSpeedSteerAngle, carStats.highSpeedSteerAngle, speedFactor);
_maxTurnSpeed = steerAngle;
if (speedFactor < 0.05f)
_maxTurnSpeed = carStats.lowSpeedSteerAngle / 2f;
// Check the moving direction
dotProduct = Vector3.Dot(transform.forward, _rigidbody.velocity);
// Calculate the motor torque
float motor = _currentTorque;
// If we moving too fast (depending on direction), then stop accelerating
if ((dotProduct > 0 && _currentSpeed > carStats.maxForwardSpeed) || (dotProduct < 0 && _currentSpeed > carStats.maxBackwardSpeed))
motor = 0f;
// For each axle in the vehicle
foreach (AxleInfo axleInfo in model.axleInfos)
{
// If the wheels are attached to the motor, then apply the torque
if (axleInfo.motor && !_hasEffect)
{
axleInfo.leftWheel.motorTorque = motor;
axleInfo.rightWheel.motorTorque = motor;
}
// If we are braking, then apply braking force and update the slip factor of each wheel
if ((_braking || _handBraking) && !_hasEffect && !_isSlowDown)
{
axleInfo.leftWheel.brakeTorque = _braking ? carStats.brakeForce : carStats.handBrakeForce;
axleInfo.rightWheel.brakeTorque = _braking ? carStats.brakeForce : carStats.handBrakeForce;
//axleInfo.leftWheel.motorTorque = 0;
//axleInfo.rightWheel.motorTorque = 0;
if (_handBraking)
{
_maxTurnSpeed = carStats.lowSpeedSteerAngle / 2f;
SetSlipping(true, axleInfo);
}
}
else if (!_moving && !_hasEffect && !_isSlowDown)
{
// If we aren't inputing vertically then apply a deceleration force depending on the vehicle speed
float decel = GetCurrentDecelerationTorque();
axleInfo.leftWheel.brakeTorque = decel;
axleInfo.rightWheel.brakeTorque = decel;
}
else if (_isSlowDown)
{
axleInfo.leftWheel.brakeTorque = 10000;
axleInfo.rightWheel.brakeTorque = 10000;
}
else
{
// If we are not braking, then don't apply any brake force
axleInfo.leftWheel.brakeTorque = 0;
axleInfo.rightWheel.brakeTorque = 0;
}
if (!_handBraking && !_hasEffect)
SetSlipping(false, axleInfo);
// If the wheels can be rotated then rotate them using the previous calculated steer angle
if (axleInfo.steering)
{
float steering = _maxTurnSpeed * _currentSteering;
axleInfo.leftWheel.steerAngle = steering;
axleInfo.rightWheel.steerAngle = steering;
}
// Finally update the visuals of both wheels
ApplyLocalPositionToVisuals(axleInfo.leftWheel);
ApplyLocalPositionToVisuals(axleInfo.rightWheel);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment