- Home /
Question by
VikoJohnson · Mar 10, 2021 at 07:24 PM ·
scripting problemgameobjectvisual studio
My problem with my "Doodle Jump" platform
Hi Guys!
I'm trying to program a game that is similar to Doodle Jump. Everything works except that a particular platform is not working properly. I can jump on it, but I can't jump through from below, I always have to jump around the platform. Can you help me?
here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Springer : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.GetComponent<Rigidbody2D>().velocity.y <= 0)
{
collision.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector3.up * 1000f);
}
else
{
if (collision.gameObject.GetComponent<Rigidbody2D>().velocity.y > 0)
{
collision.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0.0f, 10f);
Debug.Log("colisione xD");
}
}
}
}
Comment
Answer by GeroNL · Mar 10, 2021 at 09:29 PM
Try to disable your collider when it got specific collider, like when got collide active the bool ThroughtTheCollider, then when got collider and the bool true, you disable your player collider or something like that.
hope it help.