velociy? force? impulse?

hi guys, relative new to unity and have my first problem. followed a brackeys tutorial for powerups. so when my gold coin is picked up, my player changes his scale. everthing is working great except that he used the scale as an example. but my player has to move upwards. take an example of the ‘mega jump’ game, when the player hits a gold coin, he gets a force in the y direction. what do i have to change in my code? sorry for bad english and thanks :wink:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

    public class GoldCoin : MonoBehaviour
{
    public float multiplier = 2f;
    public float duration = 0.01f;

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            StartCoroutine(Pickup(other));
        }
    }

    IEnumerator Pickup(Collider2D player)
    {
        player.transform.localScale *= multiplier;

        GetComponent<SpriteRenderer>().enabled = false;
        GetComponent<Collider2D>().enabled = false;

        yield return new WaitForSeconds(duration);

        player.transform.localScale /= multiplier;

        Destroy(gameObject);
    }
}

If you’re looking for a simple solution, something like this would do. It does require that your player has a RigidBody and probably that “Uses Gravity” is ticked. Add this script to the player but you probably want to make sure that the coin is destroyed otherwise landing might cause multiple bounces…

public class Collect : MonoBehaviour

{
    [SerializeField] float jumpForce = 200;
    Rigidbody rb;

    private void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    private void OnTriggerEnter(Collider other)
    {
        rb.AddForce(Vector3.up * jumpForce);
    }
}