using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Platform : MonoBehaviour
{
public float speed = 10.0f;
private Rigidbody2D rb;
// Use this for initialization
void Start()
{
rb = this.GetComponent<Rigidbody2D>();
rb.velocity = new Vector2(-speed, 0);
}
// Update is called once per frame
void Update()
{
//not important
}
private void OnTriggerEnter2D(Collider2D other)
{
//not important
}
}
^^ This is my Platform.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformSpawner : MonoBehaviour
{
public GameObject Platform;
public GameObject Fireball;
public float respawnTime = 0.1f;
// Use this for initialization
void Start()
{
StartCoroutine(ObjectSpawning());
}
private void spawnPlatform()
{
//not important
}
private void spawnFireball()
{
//not important
}
IEnumerator ObjectSpawning()
{
while (true)
{
yield return new WaitForSeconds(respawnTime);
spawnPlatform();
spawnFireball();
respawnTime *= 1.02f;
}
}
}
^^ This is my PlatformSpawner.cs
I'm new to unity and C#, how can I change the value speed in Platform.cs from PlatformSpawner.cs ? I looked up online but I cant seem to find an answer... So I hope you guys can help me! I'm trying to gradually increase the speed value btw. Thanks in advance (: