ResourceMaker démarre le yield en hauteur, puis il descend vers le sol
This commit is contained in:
parent
e55b1c8507
commit
f9e9abe43a
@ -21,6 +21,9 @@ public class ResourceMaker : MonoBehaviour
|
||||
{
|
||||
_resourceManagerInstance = ResourceManager.Instance;
|
||||
_startPosition = transform.position;
|
||||
transform.position = new Vector2(transform.position.x, transform.position.y + 0.5f);
|
||||
gameObject.GetComponent<Rigidbody2D>().AddForce(transform.up * 20.0f);
|
||||
gameObject.GetComponent<Rigidbody2D>().gravityScale = 0.1f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -28,13 +31,19 @@ public class ResourceMaker : MonoBehaviour
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
if (Vector2.Distance(transform.position, _startPosition) < 0.01f)
|
||||
{
|
||||
gameObject.GetComponent<Rigidbody2D>().gravityScale = 0.0f;
|
||||
gameObject.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
|
||||
if (_isPlaying)
|
||||
{
|
||||
_timePassed += Time.deltaTime;
|
||||
float duration = _timePassed / _desiredTime;
|
||||
duration = duration * duration * (3.0f - 2.0f * duration);
|
||||
transform.position = Vector2.Lerp(_startPosition, _endPosition, duration);
|
||||
if(Vector2.Distance(transform.position,_endPosition) < 0.01f)
|
||||
transform.position = Vector2.Lerp(transform.position, _endPosition, duration);
|
||||
if(Vector2.Distance(transform.position,_endPosition) < 0.001f)
|
||||
{
|
||||
_isPlaying = false;
|
||||
switch (_resourceChoice)
|
||||
@ -54,5 +63,9 @@ public class ResourceMaker : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateResource(){_isPlaying = true;}
|
||||
public void GenerateResource(){
|
||||
_isPlaying = true;
|
||||
gameObject.GetComponent<Rigidbody2D>().gravityScale = 0.0f;
|
||||
gameObject.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user