top of page
Search

Platform movement

  • Writer: Keshav Batra
    Keshav Batra
  • Nov 18, 2022
  • 1 min read

Now I finally have my platforms spawning in different sizes and in different positions. They move from left to right in the vicinity. I was able to use the arrays to make the platforms spawn in different directions based on the numbers 0 to 3 since arrays always start at 0. Now all I've got to do is make sure the player is able to actually jump on the platforms.





{
   public GameObject[] Lanes;



    private void OnTriggerEnter(Collider collision)
    {
        if(collision.gameObject.CompareTag("Platform")) 
        {
            collision.transform.localScale = new Vector3(Random.Range(0.2f, 0.5f), 1, Random.Range(0.5f, 1f)); //Makes the size of the platform change

            collision.transform.position = Lanes[Random.Range(0,3)].transform.position; //Moves the platforms in the same position as the game objects
        }
    }
}


 
 
 

Comments


bottom of page