fix: unwanted ship rotations&displacement, fade audio being interrupted
This commit is contained in:
parent
5a658d6cd4
commit
c635e0a0b7
@ -188,7 +188,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 5042970769659716555}
|
||||
- component: {fileID: 4827981227876901225}
|
||||
- component: {fileID: 8355975041218818307}
|
||||
- component: {fileID: 1205453696562000256}
|
||||
- component: {fileID: 4924634183815263034}
|
||||
- component: {fileID: 2704141135220834432}
|
||||
m_Layer: 8
|
||||
m_Name: Blue Ship
|
||||
@ -229,7 +230,7 @@ Rigidbody:
|
||||
serializedVersion: 4
|
||||
m_Mass: 10
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 2560000
|
||||
m_AngularDrag: 1e+38
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
@ -246,8 +247,8 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 1
|
||||
--- !u!136 &8355975041218818307
|
||||
CapsuleCollider:
|
||||
--- !u!65 &1205453696562000256
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
@ -256,19 +257,38 @@ CapsuleCollider:
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_Bits: 256
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 247
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.3
|
||||
m_Height: 3
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0.56025195, z: 0}
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 2.5, y: 0.5, z: 0.3}
|
||||
m_Center: {x: 0, y: 1.2, z: 0}
|
||||
--- !u!65 &4924634183815263034
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1372816401649438144}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 256
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 0.5, y: 2.5, z: 0.3}
|
||||
m_Center: {x: 0, y: 0.5, z: 0}
|
||||
--- !u!114 &2704141135220834432
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -63,8 +63,9 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 5042970769659716555}
|
||||
- component: {fileID: 4827981227876901225}
|
||||
- component: {fileID: 8355975041218818307}
|
||||
- component: {fileID: 2704141135220834432}
|
||||
- component: {fileID: 7597277846063882160}
|
||||
- component: {fileID: 6404226307182575358}
|
||||
m_Layer: 8
|
||||
m_Name: Red Ship
|
||||
m_TagString: Ship
|
||||
@ -104,7 +105,7 @@ Rigidbody:
|
||||
serializedVersion: 4
|
||||
m_Mass: 10
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 2560000
|
||||
m_AngularDrag: 1e+38
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
@ -121,29 +122,6 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 1
|
||||
--- !u!136 &8355975041218818307
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1372816401649438144}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 247
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.3
|
||||
m_Height: 3
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0.560252, z: 0}
|
||||
--- !u!114 &2704141135220834432
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -159,6 +137,48 @@ MonoBehaviour:
|
||||
props: {fileID: 11400000, guid: f5590fbe0f33c0643a8df2f13af5538a, type: 2}
|
||||
boostUI: {fileID: 0}
|
||||
cameraOperator: {fileID: 0}
|
||||
--- !u!65 &7597277846063882160
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1372816401649438144}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 256
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 2.5, y: 0.5, z: 0.3}
|
||||
m_Center: {x: 0, y: 1.2, z: 0}
|
||||
--- !u!65 &6404226307182575358
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1372816401649438144}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 256
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 0.5, y: 2.5, z: 0.3}
|
||||
m_Center: {x: 0, y: 0.5, z: 0}
|
||||
--- !u!1 &5332524459205227969
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -14,6 +14,8 @@ public class ManageableAudio : MonoBehaviour
|
||||
public string audioTag = "audio";
|
||||
public AudioSource AudioSource { get; set; }
|
||||
|
||||
private bool IsUpdating = false;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (gameObject.TryGetComponent(out AudioSource audioS))
|
||||
@ -30,7 +32,7 @@ public class ManageableAudio : MonoBehaviour
|
||||
|
||||
public void PlayAudio()
|
||||
{
|
||||
if (AudioSource == null)
|
||||
if (AudioSource == null || IsUpdating || AudioSource.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -43,7 +45,7 @@ public class ManageableAudio : MonoBehaviour
|
||||
|
||||
public void StopAudio()
|
||||
{
|
||||
if (AudioSource == null)
|
||||
if (AudioSource == null || IsUpdating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -55,13 +57,18 @@ public class ManageableAudio : MonoBehaviour
|
||||
|
||||
public void FadeOutAudio(float duration = 1)
|
||||
{
|
||||
if (IsUpdating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IsUpdating = true;
|
||||
float initVolume = AudioSource.volume;
|
||||
Tween.Custom(initVolume, 0, duration, onValueChange: value => AudioSource.volume = value)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
IsUpdating = false;
|
||||
StopAudio();
|
||||
AudioSource.volume = initVolume;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ using static AffectingForcesManager;
|
||||
using ShipHandling;
|
||||
using Managers;
|
||||
using GameLogic;
|
||||
using Unity.VisualScripting;
|
||||
using Unity.Mathematics;
|
||||
|
||||
public class Ship : MonoBehaviour
|
||||
{
|
||||
@ -95,21 +97,19 @@ public class Ship : MonoBehaviour
|
||||
/// </summary>
|
||||
void UpdateMovement()
|
||||
{
|
||||
if (state.thrustInput > 0)
|
||||
if (math.abs(state.thrustInput) > 0)
|
||||
{
|
||||
if (!ThrusterSound.AudioSource.isPlaying)
|
||||
{
|
||||
ThrusterSound.PlayAudio();
|
||||
}
|
||||
ThrusterSound.PlayAudio();
|
||||
}
|
||||
else
|
||||
{
|
||||
ThrusterSound.StopAudio();
|
||||
ThrusterSound.FadeOutAudio(0.3f);
|
||||
}
|
||||
|
||||
//Debug.Log("inupdatemove " + currentThrustInput);
|
||||
// Player rotation is always possible and same speed
|
||||
transform.Rotate(0, 0, -props.steerVelocity * state.steerInput * Time.deltaTime);
|
||||
transform.localEulerAngles = new Vector3(0, 0, transform.localEulerAngles.z);
|
||||
|
||||
// Get and apply the current Gravity
|
||||
state.currentGravity = forceManager.GetGravityForInstance(InstanceID)(transform);
|
||||
@ -156,9 +156,10 @@ public class Ship : MonoBehaviour
|
||||
// Default torque drag
|
||||
body.AddRelativeTorque(body.angularVelocity * -props.torqueDrag, ForceMode.Acceleration);
|
||||
|
||||
|
||||
Debug.DrawRay(transform.position, transform.up * (currentVelocity.magnitude + 3) * 0.5f,
|
||||
Color.black);
|
||||
|
||||
body.transform.localPosition = body.transform.localPosition - new Vector3(0, 0, body.transform.localPosition.z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -310,6 +311,7 @@ public class Ship : MonoBehaviour
|
||||
/// <param name="collider">Object which has collided with the collision region.</param>
|
||||
void StartTackleResponse(TackleKind tackleKind, Collider collider)
|
||||
{
|
||||
// TODO: The one who tackled first should be exempt from knockback in some way
|
||||
float tacklePowerFactor = props.criticalTacklePowerFactor;
|
||||
if (tackleKind == TackleKind.Critical)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user