How to make so that the player can jump on a object, but he can't stand on it? (2D)
I have already done this, on pc it works perfectly, but on mobile it doesn't. I don't know why. And for the platform I just set it as ground, and I set it as a trigger, so the player can fall through. I add a another component a little bit bellow the platform. If the player collides with it it disables the platform and enables it again after some time. Here is the code I made for it:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class OnlyJumpPlatform : MonoBehaviour
{
public AudioSource soundOfBreaking;
public GameObject platform;
public GameObject alsoSoundOfBreaking;
void OnTriggerEnter2D(Collider2D other)
{
soundOfBreaking.Play();
platform.SetActive(false);
}
void OnTriggerExit2D(Collider2D other)
{
Invoke("Spawn", 3f);
Invoke("Sound", 1f);
}
void Spawn()
{
platform.SetActive(true);
alsoSoundOfBreaking.SetActive(true);
}
void Sound()
{
alsoSoundOfBreaking.SetActive(false);
}
}
Is there any way I can improve this so that it works on mobile?
Comment