How to move ball by a "Z axis"?

From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Hey guys

    I'm simulating a 3d environment where a ball can move in X,Y and a fake Z axis.

    I have a shadow for the ball that will obviously be always in the ground so when the ball touches this shadow it will bounce as if hit the ground.

    The shadow will of course follow the ball.

    If the ball moves back or forward, when in air, the X position of the shadow will follow it while the Y keeps its position.

    But when the ball moves in diagonal, the shadow's Y will need to follow it too but keeping a certain distance to look like the ball is in air above the ground. I cant figure out how to do this.

    Here's my capx and an image

    https://drive.google.com/file/d/1ZeT6-Mfh-4F0lx5cV1_1-sB4Hv1C4afd/view?usp=sharing

    Apreciate any help

  • You need to provide access to your c3p file. It's currently locked.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Create instance variable zscale and set it to 1

    Then every tick set ball.Self.zscale to ball.Self.zscale-zspeed*dt

    Stationary ball would be its original size because zesale is set to 1

    zspeed would be another variable, what the actual number is would depend on how hard you hit the ball. Once you get that going ball will start getting smaller and smaller simulating movement in z axis

    You should make sure ball.Self.zscale never goes below 0, and not much over 1

    You will also have to move the ground up as the ball gets smaller. I figured out a formula for this a while back, but I don't eremember it exactly

    something like variable startground = 600

    then ground = startground - (1-ball.zscale)*100 You will have to play with numbers until it looks right. In my example ball would fall down to Y of 600 when scale is at 1, then hit the ground at Y of 500 when scaled all the way to 0.1 or smaller.

    Shadow Y always set to ground. Adjust shadow scale and opacity tomatch height of the ball. Higher the ball, bigger the shadow, but lower its opacity and the other way around.

    Shadow X is same as ball X

  • thank you BadMario helped me a lot

    oosyrag, could you explain these formula please?

    I'm trying to use this system in a game where characters must chase the ball and bounce it to not let it fall on ground

  • make the actual position be the shadow, and set the ball'S position to the shadow + z

  • In event 1, it the underlined are randomizing the particle (ball) properties. Depending on the angle chosen, the speed of the bullet is adjusted due to the isometric perspective. Vertical motion should appear slower than horizontal motion.

    In event 2, it is adjusting the scale of the ball depending on how far it is from the base - as the ball bounces higher it gets slightly bigger.

    Edit: The formulas were just for a more accurate representation or the isometric perspective. They aren't strictly necessary, you can just pick a random direction and speed and fire them off if you wanted.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)