вот код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AllShapesJump : MonoBehaviour
{
private Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
rb.mass = 0.7f / GameObject.FindGameObjectWithTag("Player").GetComponent<Controller>().numberOfShapes;
}
public void ShapesJump()
{
if (Mathf.Abs(rb.velocity.y) < 0.05f)
rb.AddForce(new Vector2(Random.Range(-20f, 20f), 30f), ForceMode2D.Impulse);
}
}
?