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

142
Visualizações
My player slides off moving platform. Javascript canvas game

I'm trying to get my player to stay on the moving platform. Possibly need to add something in here? Gravity? I'm still pretty new at this.

export function collisionTop({ object1, object2 }) {
  return (
    object1.position.y + object1.height <= object2.position.y &&
    object1.position.y + object1.height + object1.velocity.y >=
      object2.position.y &&
    object1.position.x + object1.width >= object2.position.x &&
    object1.position.x <= object2.position.x + object2.width
  )
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If I read correctly, the problem you have is that the player does not move when the platform it is standing on moves. To fix this problem, whenever you move the platform, you should check if the player is standing on the platform (with a collision function), then if the player is standing on the platform, move the play the same distance in the same direction as the platform you are moving. It might look something like this (I don't know your code, so this is a rough guess):

function movePlatform(dx, dy) {
    if (collisionTop(player, platform)) {
        player.position.x += dx;
        player.position.y += dy;
        platform.position.x += dx;
        platform.position.y += dy;
    }
}
about 4 years ago · Juan Pablo Isaza 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