Wrong direction of gravity

Wrong direction of gravity
0

#1

I am currently making a projected trajectory with this tutorial: https://www.iforce2d.net/b2dtut/projected-trajectory
Using the same formula with the author, I made the projected trajectory but the direction of the gravity seems quite wrong, it heading to the bottom left of the screen like showing on this image:

My drawing code is like this:

getTrajectoryPoint: function(pos, velocity, n) {
    var t = 1/10;
    var stepGravY = t*t*cc.director.getPhysicsManager().gravity.y;
    return cc.p(pos.x + n*t*velocity.x + 0.5*(n*n + n)*stepGravY, pos.y + n*t*velocity.y + 0.5*(n*n + n)*stepGravY);
},

#2

Hi, I haven’t seen that tutorial but if you’re doing a “Projectile motion” then the x component should not be affected by the gravity at all


#3

Thanks it worked. Shame for me that’s some basic physics knowledge.


#4

You can use cc.jump


#5

but that cause jerks in ball the case he is dealing with.


#6

@ginrex can you share any code snippet please. Also some more good resources.


#7

Sorry I didn’t think someone could go back to this game lol, anyway sorry but I don’t have the project with me anymore. As far as I remember, the problem was that I tried to adjust the x-axis of the projected trajectory based on gravity, it was pointed out by zerodarkzone that it was just a fail in my formula lol.


#8

thanks for response. okay i check it out.