I’m trying to make the trajectory of ball before the use of force.
the example of the realisation in box2d, got from Phaser examples
function getTrajectoryPoint(startX, startY, velocityX, velocityY, n) {
//velocity and gravity are given per second but we want time step values here
var t = 1 / 60.0; // seconds per time step (at 60fps)
var stepVelocityX = t * game.physics.box2d.pxm( -velocityX ); // m/s
var stepVelocityY = t * game.physics.box2d.pxm( -velocityY );
var stepGravityX = t * t * game.physics.box2d.pxm( -game.physics.box2d.gravity.x ); // m/s/s
var stepGravityY = t * t * game.physics.box2d.pxm( -game.physics.box2d.gravity.y );
startX = game.physics.box2d.pxm(-startX);
startY = game.physics.box2d.pxm(-startY);
var tpx = startX + n * stepVelocityX + 0.5 * (n*n+n) * stepGravityX;
var tpy = startY + n * stepVelocityY + 0.5 * (n*n+n) * stepGravityY;
tpx = game.physics.box2d.mpx(-tpx);
tpy = game.physics.box2d.mpx(-tpy);
return { x: tpx, y: tpy };
}
any idea and thoughts how to do it in Defold?