[2D] How to grab and throw an object backward?

I’m trying to make a game where a player stand behind an object and throw it in the back ( behind the player) … it is a platform/ racing game… the players would be running and when there is an obstacle in front of the them, they will be able to grab it and throw it behind them

Hi @unity_xGSevXjAMNMB3w, here the code to throw an item based on the direction the player is facing. The movement, how to decide where the player is facing, … is of course not included.
I will not include the code to pick up an item as this took me way longer than expected, I’m not used to 2D. Basically what you should do is check if the player collider is interacting with the object collider. This way you know the player is close to the object.

using UnityEngine;

public class Player : MonoBehaviour
{
    [SerializeField] private float _power = 7.5f;
    private Rigidbody2D _pickedUpItem;
    private bool _facingRight = true;
    private bool _readyToThrow = false;


    void FixedUpdate()
    {
        if (Input.GetAxisRaw("Pickup") == 1)
        {
            // pick up item
        }

        if (Input.GetAxisRaw("Throw") == 1 && _pickedUpItem)
        {
            ThrowItem(_pickedUpItem);
            _readyToThrow = true;
        }

        if (Input.GetAxisRaw("Throw") == 0 && _pickedUpItem)
        {
            _readyToThrow = false;
        }
    }
    
    private void ThrowItem(Rigidbody2D item)
    {
        if (!_readyToThrow)
        {
            item.AddRelativeForce(new Vector2(_power * (_facingRight ? -1 : 1), _power), ForceMode2D.Impulse);
        }
    }
}

I can’t imagine you’ll get the sort of reply you’re looking for with so little detail. I can’t answer your question but those that can will probably need to know more details like what type of game it is. Is it a platformer? Is it top down? Isometric? The users on this help forum need more information to go on. Sorry this doesn’t answer you’re question.