Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
How to make the player jump up automatically when standing on a specific block in Unity?

(please forgive me for my bad coding skills)

So im trying to make a jumppad in unity where, if the player stands on the jump pad, the player automatically gets shot up into the sky.

float height = 50f;

else if (onJumpPad)
        {
            while (true) {
                velocity.y += 1;
                height -= 1;

                if (height == 0)
                {
                    height = 50f;
                    break;
                }
            }
        }

above is the half-working code. I have to jump ON the jump pad to make the player get shot up into the sky.

Any help is appreciated.

(I know that the height variable should not belong in the middle of the else if statement, I just wrote it for demonstration purposes).

full code here = https://pastebin.com/3ZVu5bUq

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think you might need kind of jump pad. So First of all don't forget to add a collider on block as much height and width as you need. Then you can check with OnTriggerEnter or OnCollisionEnter. For Example:-

I have a block named jumpPad. I added a box collider on that with full of width and with minimum height. I didn't checked IsTrigger so I have to use OnCollisionEnter. Now what I will write in code inside player script is:-

    void OnCollisionEnter(Collision other)
    {
       if(other.gameObject.CompareTag("jumpPad")
       {
           GetComponent<Rigidbody>().AddForce(Vector3.Up * force);
       }
    }

In this code force is already declared somewhere in script. Also make sure to give block a tag if you are using CompareTag or .tag == "jumpPad". Also you need to add rigidbody component to player object.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda