void FixedUpdate() { Triggered(); if (_up) { _rigidbody2D.AddForce(Vector2.down * _speed); _slowMovement.Coroutine(); _up = false; } if (_left) { _rigidbody2D.AddForce(Vector2.right * _speed); _slowMovement.Coroutine(); _left = false; } if (_right) { _rigidbody2D.AddForce(Vector2.left * _speed); _slowMovement.Coroutine(); _right = false; } if (_down) { _rigidbody2D.AddForce(Vector2.up * _speed); _slowMovement.Coroutine(); _down = false; } //_slowMovement.rigidbody2D = _rigidbody2D; }
void Start() { _slowMovement = GetComponent <SpeedBehaviour>(); _rigidbody2D = GetComponent <Rigidbody2D>(); _keyInput = GetComponent <InputBehaviour>(); _player_Health = GetComponent <Player_Health>(); _slowMovement.Coroutine(); }
void FixedUpdate() { if (_speed > 0) { _rigidBody2D.AddForce(new Vector2(x, y) * _speed * Time.deltaTime * 2); _speed -= .5f; _speedBehaviour.Coroutine(); } if (_speed == 0) { _speed = 0; } }