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
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);
}
}