@mykgo2011

NullReferenceException: Object reference not set to an instance of an object AllShapesJump.Update () (at Assets/Scripts/AllShapesJump.cs:16)?

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

}
  • Вопрос задан
  • 27 просмотров
Пригласить эксперта
Ответы на вопрос 1
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы