Legacy GM Make ball travel in curve

mar_cuz

Member
Hi GMC,

I'm having trouble making the ball in my sports game travel in curve or arc. Using a gamepad at the moment I get the direction from the player left joystick, speed of the ball is determined by how long player presses X then every step ball speed is decreased by -0.01. How could I make the ball travel in the same direction as the player but at a curve/arc.

Thanks.
 

NicoFIDI

Member
you want a ball like a tennis ball (platform ark) or a rotating ball like the roulet ball (circle movement)?
or maybe the image of a ball rolling?
 

mar_cuz

Member
Are you trying to make it look like the ball is going up in the air? I don't really follow what you are trying to do.
Hi Pope sorry I should have been more clear. I already have the z depth for the ball so it goes up in the air and comes down. If you imagine kicking a soccer ball and it curves left or right while in the air that's what I'm trying to do. I'm working with the perspective in the image attached.
 

Attachments

mar_cuz

Member
you want a ball like a tennis ball (platform ark) or a rotating ball like the roulet ball (circle movement)?
or maybe the image of a ball rolling?
So in the post above, see the picture in that perspective, I you kick the ball upwards, I'm after the ball to travel at a curve left or right, and if you were to kick the ball left or right the ball to curve up on down.
 
So you are essentially asking to put "spin" on it. One way you could do this is to apply a sort of "gravity" to the ball as it travels. Essentially you can't just move it in one direction, you need to be constantly updating it's direction to get a curve.
 

NicoFIDI

Member
Mhm....
into the ball
on create
Code:
/// Initialize values
speed = 1;
direction = 0;
momentum = 0;
angular_inertia = .1; // from 0 to 1 positive if you want normal behaviour
(with other object you change it's momentum)
step
Code:
/// move with curve
direction += momentum;
momentum *= 1-angular_inertia;
you shoot the ball with a direction below or over the actual direction and apply a momentum
 

NinjaGMC

Member
If you're using Physics, some type of Gravity would work. Start with putting an angle or direction on the object 1st.
 

mar_cuz

Member
Mhm....
into the ball
on create
Code:
/// Initialize values
speed = 1;
direction = 0;
momentum = 0;
angular_inertia = .1; // from 0 to 1 positive if you want normal behaviour
(with other object you change it's momentum)
step
Code:
/// move with curve
direction += momentum;
momentum *= 1-angular_inertia;
you shoot the ball with a direction below or over the actual direction and apply a momentum
Thanks I'll give the code a try after work today.
 
Top