Hi. I am starting my first long term project with the platform, and I wanted to use the 2D Microgame as a base. Everything has worked fine - Even swapping out the animations, but I can’t manage to get the player to pass through a platform with the component applied. I’ve tried butting it above the player, across from it, nothing seems to work. I’m not sure if this is a known issue that they are trying to fix, or if it has only popped up for me. If needed, I can rewrite the movement script, though that might lead to more issues.
Check the layering… both what the different pieces are using as well as what the physics system is set to ignore.
And of course verify you have the “Uses Effector” checkboxes everywhere they need to be!
I can verify that the “Uses Effector” variable is set to true and that they are on the same layer with the correct layering.
Did you check the actual physics collision matrix? You can set a layer to ignore itself.
More cross-checking:
-
make what works in another (empty) project, export it as a .unitypackage, pull it into the game where that’s not working. Does it work
-
and reverse (see if the broken one runs okay on the empty project).
I’ve checked the collision matrix and everything is checked. I also tried that when I first encountered this error. It didn’t work, to say the least. I think that the Kinematic rigidbody on the player might be what’s wrong, so I’m experimenting with that right now.
A kinematic body won’t stop for collisions anyway so that really doesn’t make sense.
I might end up rewriting the movement script, though I really don’t want to have to do that.
Sounds like you’re modifying stuff without understand stuff well which is fine but the title of the thread seems to indicate a problem with Unity or the project itself. Your reply isn’t clear on what it actually means. You didn’t reply to my comment specifically so it’s impossible to help without you providing more information.
Ok. I have worked with Unity in the past, but I never had the time to understand kinematic rigidbodies. I’ve worked with static and dynamic, though not with kinematic. It might be something in the project settings or script itself, since I tried putting a simple sphere in game while running that had a rigidbody2D component attached to it and it passed through just fine, so it might be the script.
Sorry for the quick response, but I found what’s wrong and It’s with the script. In the Kinematic Object script, which the player controller seems to reference, there is a line that says:
//We are airborne, but hit something, so cancel vertical up and horizontal velocity.
velocity.x *= 0;
velocity.y = Mathf.Min(velocity.y, 0);
So, this might me what’s wrong. EDIT: No. Didn’t work.
Great news! I managed to fix the error, after a lot of hours wasted on trying to fix an error I couldn’t, I just made a script that I attached to the object that replaced the effector with a simple script that allows me to, if holding W or S, to pass through the collider! Here’s the code for anyone else with the error.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class TilemapPlatformEffector : MonoBehaviour
{
public TilemapCollider2D colliderPlatform;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
colliderPlatform.enabled = false;
}
if (Input.GetKeyUp(KeyCode.Space))
{
colliderPlatform.enabled = true;
}
if (Input.GetKeyDown(KeyCode.S))
{
colliderPlatform.enabled = false;
}
if (Input.GetKeyUp(KeyCode.S))
{
colliderPlatform.enabled = true;
}
}
}
But the title of the thread is related to the PlatformEffector2D and the one-way is about enabling/disabling contacts for Dynamic bodies. I have no idea how it relates to you using a Kinematic body. It’s not clear how the PlatformEffector2D relates to what you’re doing here. I also see the TilemapCollider2D in the code above which makes it even more confusing.
Anyway, glad you’ve got whatever it is you’re doing working.
Good luck.