One-Way platform

Does anybody have an example of one-way platforms with the truesync 2D physics engine? I have an existing Unity project where I used platform effectors, but I don't see anything matching that in the TrueSync package...

https://docs.unity3d.com/Manual/class-PlatformEffector2D.html

Comments

  • // Fall through platforms if (onRealGround) grounded = true; if (!onRealGround) { if (jumpInput < 0) layerSwapTimer = 0; layerSwapTimer += TrueSyncManager.DeltaTime; if (layerSwapTimer >= 0.15f && tsRigidBody2D.velocity.y <= 0f) { if (team == 1) { gameObject.layer = LayerMask.NameToLayer ("Player On Platform"); } if (team == 2) { gameObject.layer = LayerMask.NameToLayer ("Player2 On Platform"); } } if (layerSwapTimer < 0.15f || tsRigidBody2D.velocity.y > 0.1f) { if (team == 1) { gameObject.layer = LayerMask.NameToLayer ("Player"); } if (team == 2) { gameObject.layer = LayerMask.NameToLayer ("Player2"); } } if (tsRigidBody2D.velocity.y <= -1.5f) grounded = false; }

    Platforms are on a layer that don't collide with Player/Player2.
  • In addition, What I just recently did was add a trigger version of the player's collisionbox (also serves as the hitbox), which is on a static layer that does collide with everything. When it triggers on a platform, I tell it to set a bool to true. I made "Player On Platform" only happen if this bool turned up true, so now the player doesn't turn his collision on if he's currently 'inside' of a platform.

    Though the main problem with changing the layers around is that it messes with TS's physics speculations so the player might occasionally dip into the ground at times, even with Speculative Contact on.
  • Thank you very much! Right now I'm thinking your first idea of overriding the vertical velocity will be easier for my systems...

    (Was hoping for something a bit more click & drag, but such is life...)