Hallo Leute!
Ich versuche ein Spiel zu programmieren, das Doodle Jump ähnelt. Alles funktioniert, außer dass eine bestimmte Plattform nicht richtig funktioniert. Ich kann darauf springen, aber ich kann nicht von unten durchspringen, ich muss immer um die Plattform springen. Könnt ihr mir helfen?
Hier ist mein Skript:
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");
}
}
}
}