web analytics

One Way Platform in Unity 5 : Most Efficient Way

Many developers struggle with one way platform , but in Unity 5 it’s quite easy . No need of any coding .You will find many tutorials on “How to make One Way platform” and every tutorial is different but this is the end point . This post shows you the most simplest way to create one way platform.

1. Ok so what we need is a scene setup like the below

one way platform 1

 

 

2.  Select the Bottom Platform and a Box Collider 2D component to it.

3.  Select the player and add a rigidbody 2D component and a Circle Collider 2D . Also add the below script.

 

using UnityEngine;
using System.Collections;

public class Force : MonoBehaviour{

   // Update is called once per frame
   void Update ()
   {
           if (Input.GetKeyDown (KeyCode.Space))
                 GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, 280f));
   }
}

 

4.  Now Select the Top platform and add a Box Collider and a Platform Effector 2D
one way platform 2

* Platform Effector 2D is added in Unity 5

 

5. Now run the game and press Space Key and see the magic.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *