Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unity2d create a one side collider

I have a maplestory game demo

I need character can jump through a collider from one side

the collider in my character and ground are like this:

character:capsulecollider2d

ground:polygoncollider2d

enter image description here

so the character can stand on the ground

enter image description hereenter image description here

also can jump on the ground

but now I want character jump from bottom of the ground,it cannot work

enter image description here

so, How can I deal this problem? Is there a configuration that can make collider only have one side?

-------------------------------------2017 08 11-------------------------------------

thanks a lot every one

thank you @EmreE @Jeroen De Clercq

I resolved this problem by using Platform Effector 2D provided by @EmreE

enter image description here

first: add platform effector 2d on my ground and select "use one way"

second:select "Used by Effector"

enter image description here

now it works :)

enter image description here

like image 874
Martin Avatar asked Aug 10 '17 16:08

Martin


1 Answers

  • Put your floor in a layer;
  • put your platforms in a layer;
  • When you jump remove collision with platform layer until u have reached a direction that points towards the floor.
  • When you press down key remove collision with platforms until you have passed one platform layer.

More information here ; https://docs.unity3d.com/ScriptReference/Physics.IgnoreLayerCollision.html

like image 130
Jeroen De Clercq Avatar answered Nov 18 '22 11:11

Jeroen De Clercq