Calling a function from another script

Instead of using a 2nd script I wrote this down:

using UnityEngine;
using System.Collections;

public class BlockSizeAndPosition : MonoBehaviour {

    public int Distance;
    public GameObject Player;
    public GameObject[] Blocks = new GameObject[9];

    private float NewRespawnTime = 4;

    void Start() {
        InvokeRepeating ("ChooseBlock", 2, NewRespawnTime);
    }

/////The changes made are below/////

    void Update() {
        if (Mathf.Approximately(Mathf.Floor(Time.time / 5), Mathf.Floor(Time.time % 5)) && NewRespawnTime > 0.5f) {
            NewRespawnTime -= 0.5f;
        } else if (NewRespawnTime == 0.5f) {
            NewRespawnTime = 0.5f;
        }
        Debug.Log (Time.time + ", " + NewRespawnTime);
    }

/////Rest of the script/////

Now the problem is that it changes really fast to 0.5 since the updates are happening really fast and the conditions are still true, any suggestions on how to fix this?

Put public static before the function, and do:GetComponent().functionname();

I made a few changes but still thank you :slight_smile:

As a general rule no. Static is not designed for script to script communication.

Here is a video I made on the topic.

https://www.youtube.com/watch?v=iO5ADWj9g3Y