JetPack
This commit is contained in:
@@ -17,7 +17,8 @@ public class JetPack : MonoBehaviour
|
||||
public BoxCollider Collider;
|
||||
public SphereCollider Trigger;
|
||||
public Rigidbody Rigidbody;
|
||||
public ParticleSystem Particles;
|
||||
public Transform Load;
|
||||
public ParticleSystem[] Particles;
|
||||
public InputActionAsset InputActions;
|
||||
}
|
||||
|
||||
@@ -64,16 +65,24 @@ public class JetPack : MonoBehaviour
|
||||
{
|
||||
if (_jumpAction.IsPressed())
|
||||
{
|
||||
_wasPressed = true;
|
||||
_duration -= Time.deltaTime;
|
||||
_smooth = Mathf.Clamp01(_smooth + Time.deltaTime);
|
||||
//Player.Instance.SetExtraForce(Vector3.up * _settings.Force * _smooth, true);
|
||||
}
|
||||
else if (_wasPressed)
|
||||
else
|
||||
{
|
||||
_smooth = 0;
|
||||
_wasPressed = false;
|
||||
ResetExtraForce();
|
||||
_smooth = Mathf.Clamp01(_smooth - 2 * Time.deltaTime);
|
||||
}
|
||||
|
||||
Player.Instance.SetForce(Vector3.up * _settings.Force * _smooth);
|
||||
|
||||
_references.Load.localScale = new Vector3(1, _duration / _settings.Duration, 1);
|
||||
|
||||
foreach (ParticleSystem pSystem in _references.Particles)
|
||||
{
|
||||
if (!pSystem.isPlaying && _smooth >= .1f)
|
||||
pSystem.Play();
|
||||
if (pSystem.isPlaying && _smooth <= .05f)
|
||||
pSystem.Stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -106,7 +115,7 @@ public class JetPack : MonoBehaviour
|
||||
if (!_state.Equiped)
|
||||
return;
|
||||
|
||||
ResetExtraForce();
|
||||
Player.Instance.SetForce(Vector3.zero);
|
||||
|
||||
_state.Equiped = false;
|
||||
_duration = _settings.Duration;
|
||||
@@ -119,11 +128,11 @@ public class JetPack : MonoBehaviour
|
||||
_references.Trigger.enabled = false;
|
||||
_references.Rigidbody.isKinematic = false;
|
||||
_references.Rigidbody.AddRelativeTorque(random, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
_references.Load.gameObject.SetActive(false);
|
||||
|
||||
private void ResetExtraForce()
|
||||
{
|
||||
//Player.Instance.SetExtraForce(Vector3.zero, false);
|
||||
foreach (ParticleSystem pSystem in _references.Particles)
|
||||
if (pSystem.isPlaying)
|
||||
pSystem.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user