top of page
Search

3D Platformer

  • Writer: Keshav Batra
    Keshav Batra
  • Oct 28, 2022
  • 1 min read

I've now completed the infinite moving platforms for my player to jump on. I achieved this by using collision.transform.position. I then used vector3 which holds the x, y, and z axis. The y axis controls the up and down positions. Once the platforms hit the trigger box, they automatically get teleported back to the top. Here's the code for the platforms:



{
   public GameObject Platform;
   private float y = 15f;
   private float x;

   private float z;


    private void OnTriggerEnter(Collider collision)
    {
        if(collision.gameObject.CompareTag("Platform")) 
        {
            collision.transform.position = collision.transform.position + new Vector3(x,y,z); //Repeats the movement of the platforms
        }
    }
 


 
 
 

Kommentare


bottom of page