void FixedUpdate() { if (stickSide != lastStickSide) { lastStickSide = stickSide; calculateDirections(); } applyMovement(); }
// Start is called before the first frame update void Start() { if (!rigidbody) { rigidbody = GetComponent <Rigidbody2D>(); } if (!transform) { transform = GetComponent <Transform>(); } if (!collider) { collider = GetComponent <Collider2D>(); } rigidbody.isKinematic = true; rigidbody.freezeRotation = true; lastStickSide = stickSide; calculateDirections(); }