Phempt Posted November 20, 2014 Share Posted November 20, 2014 Hi guys, I've a character (collision group 0) that can jump on a platform (collision group 4). This is my collide function:else if (other.collisionGroup === 4) { if (player.last.y + player.shape.height / 2 <= other.position.y - other.shape.height / 2) { player.onGround = true; player.mass = 1; player.velocity.y = player.velocityLimit.y; } else return false;}is it possible to detect when collision between character and group 4 end in order to set player.onGround on FALSE? Thank you Quote Link to comment Share on other sites More sharing options...
Phempt Posted November 21, 2014 Author Share Posted November 21, 2014 I solved with this 3 lines in the update function://console.log("last: "+lastPosY+" new: "+player.position.y); if (player.position.y > lastPosY) { player.onGround = false; } lastPosY = player.position.y;is there a better way? Quote Link to comment Share on other sites More sharing options...
enpu Posted November 21, 2014 Share Posted November 21, 2014 There is afterCollide function on body, that is called after collision is solved. Maybe that can help you? Quote Link to comment Share on other sites More sharing options...
Phempt Posted November 21, 2014 Author Share Posted November 21, 2014 I'll try because I don't like that the update function continuously checks the y variations. Quote Link to comment Share on other sites More sharing options...
Phempt Posted November 21, 2014 Author Share Posted November 21, 2014 I tried but in my case the resources usage is the same. Thank you anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.