c# - Jumping onto a platform -


i making 2d platform game in untiy android , having issues section of code have. when jump onto platform first time can land onto platform when jump again fall through platform. have box collider inactive if player less height of platform , active when player higher platform. thought box collider small , missing collider have tried different sizes of colliders , have tried adjusting different heights @ activates. when set height low player double jump. doing wrong?

public class rock : monobehaviour  {     private boxcollider2d platform;     private playerscript player;      public float height;      void awake() {         player = gameobject.find("player").getcomponent<playerscript>();         platform = getcomponent<boxcollider2d>();     }      void start () {         platform.enabled = false;     }      // update called once per frame     void update () {         if(player.transform.position.y > height){             platform.enabled = true;         } else if(player.transform.position.y < height){             platform.enabled = false;         }     } } 

could you're not covering case player.transform.position.y == height? can see you're checking greater / smaller height not equality. lead unwanted behavior 1 you're describing.

let me know if problem.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -