Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

BUG? Player colliding when should not

Discussion in 'Project Tiny' started by developer_plus, Apr 8, 2019.

  1. developer_plus

    developer_plus

    Joined:
    Jan 10, 2017
    Posts:
    10
    my player is walking over a collider, but when that ends, the player don't fall, just still going straight like if it was over a collider, but if I press to jump it falls down. How can I fix it?

    The player has a rigidbody.

    jump code:
    Code (CSharp):
    1. if (ut.Runtime.Input.getMouseButtonDown(0)) {
    2.                                     this.playClip("jumpAudio");
    3.                                     const physicsConfig = this.world.getConfigData(ut.Physics2D.Physics2DConfig);
    4.                                     physicsConfig.gravity = new Vector2(0, -30);
    5.                                     this.world.setConfigData(physicsConfig);
    6.                                     let vel = new ut.Physics2D.SetVelocity2D;
    7.                                     vel.velocity = new Vector2(0,0);
    8.                                     let impulse = new ut.Physics2D.AddImpulse2D;
    9.                                     impulse.impulse = new Vector2(0, player.jumpForce);
    10.                                     this.world.addComponentData(entity, vel);
    11.                                     this.world.addComponentData(entity, impulse);
    12.                                 }
     
  2. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    It might be because your changing the pivot of your collider.

    Iv noticed you have to move the collider around with the transform and leave its pivot at (0.5, 0.5)