fix HammerThrower

This commit is contained in:
2026-06-06 11:50:19 +03:00
parent a1420ed339
commit ab5d62d20d
5 changed files with 34 additions and 17 deletions
@@ -47,6 +47,7 @@ public class PlayerController : Character
Vector2 move = _inputManager.Movement;
MoveTo(move.x, isAllowVertical ? move.y : 0);
_hammerThrower.SetFacingDirection(_facingRight);
}
private void OnFireButtonPressed()
+10 -7
View File
@@ -27,15 +27,18 @@ public class HammerThrower : MonoBehaviour
_currentHammer = Instantiate(_hammerPrefab, _spawnPoint.position, _spawnPoint.rotation);
float direction = _facingRight ? 1f : -1f;
//float direction = _facingRight ? 1f : -1f;
var rb = _currentHammer.GetComponent<Rigidbody2D>();
rb.linearVelocity = new Vector2(direction * _throwSpeed, 0);
//var rb = _currentHammer.GetComponent<Rigidbody2D>();
//rb.linearVelocity = new Vector2(direction * _throwSpeed, 0);
// Flip hammer visually
var scale = _currentHammer.transform.localScale;
scale.x = Mathf.Abs(scale.x) * direction;
_currentHammer.transform.localScale = scale;
//// Flip hammer visually
//var scale = _currentHammer.transform.localScale;
//scale.x = Mathf.Abs(scale.x) * direction;
//_currentHammer.transform.localScale = scale;
_currentHammer.transform.localScale = new Vector2(_currentHammer.transform.localScale.x * (_facingRight ? 1 : -1), _currentHammer.transform.localScale.y);
_currentHammer.GetComponent<Rigidbody2D>().linearVelocity = new Vector2(gameObject.transform.localScale.x * _throwSpeed, 0);
}
private void Update()