Пример #1
0
 private void PerformFloatToPlayerBehavior()
 {
     //this method will perform that this thing will float to the player
     if (CheckIfPlayerInRadius() && CheckIfPlayerIsNotFull())
     {
         PerformMoveToPlayer();
     }
     else if (!CXMathFunctions.CheckFloatInRange(rigidBody2D.velocity.x, -.5f, .5f))
     {
         float   newVelocityX = Mathf.Lerp(rigidBody2D.velocity.x, 0, CXMathFunctions.Map(itemDampSpeed, 0f, 100f, 0f, 1f));
         Vector2 newVelocity  = new Vector2(newVelocityX, rigidBody2D.velocity.y);
         rigidBody2D.velocity = newVelocity;
     }
 }