How do I make an 8 Ball Pool 3D ball effect?

0 favourites
  • 6 posts
From the Asset Store
Enjoy the powerful simulation with accurate ball physics, build with realistic ball spinning animations
  • When a ball gets hit by physics, as it moves and rotates so should it's texture like below:

  • I think the way to do it would be to have a frame for every angle.

    X rotation from 0 to 360

    Y rotation from -180 to 180

    So if you wanted a frame for each 10 degrees that would be 36*36 frames.

    So the next step is to map an x,y angle to a frame. Z is handled by the sprite angle. A starting formula could be this:

    36*int(angX/10)+int(angy/10)

    X and y could be swapped depending on how your frames are laid out. You also want to ensure the angle is in the range 0 to 360. This should do it:

    Ang=(Ang%360+360)%360

    Ok cool. So all that’s left is to rotate the ball around in 3D somehow. I’m thinking just some physics. Simple case you’d want it to roll in the direction the ball is moving. Looks like it can spin in place in your gif. Might need some more 3D physics calculations. But I can’t calculate that off the top of my head.

  • Just a thought. In C3 you could offset the texture of a Tiled Background using some trig for the direction angle. Then use a blend mode for a cutout mask. Not quite 3d, but kind of close.

    R0J0hound I think you made a plug for C2 that would work the same.

  • I read this post before going to bed and tried to solve it in my sleep lol :)

    In my dream I was using an effect that applies spherical texture to ball sprites. And what do you know - there is such effect!

    construct.net/en/make-games/addons/242/glsl-sphere

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you all so much!

    R0J0hound

    newt

    dop2000

    Reading yesterday evening, first wanted to try newt's approached since we both had a similar and a bit easier thing in mind, so I made a texture and applied a source atop blend mode and made it so that multiple textures adjust over the ball via speed as it spins and it worked, went to sleep to finish "texture looping" today.

    Seeing dop's great dream discovery seems way less tedious, so thank you for that one, guess I'll roll with that for now! :D

    I haven't yet therefore tried yours R0J0 since trying the other one first would've taken less time, no idea how you came up with that approach, I'm curious how it'd work so might try it out when I have some free time, thank you as well!

  • Hi, just wanted to leave a note here, don't bother with the glslSphere addon, is not working properly. plus you need 2 sets of sprites, one that has the physics behavior and the glslSphere on top of that to fake the rotation 3d... but the rotation speed Z XY axes are broken, original code was like that incomplete, so i just ported what was there.

    1999 pro pool < somehow this dudes, managed to fake the 3d rotation pretty good, and choppy back in 2000 or somewhere there... but we can't in 2021 well... it's a shame. i think your best bet, would be to use three.js and create an actual 3d sphere on top of your 2d sprite, and somehow have that 3d sphere use torque to spin like on contact with a floor. it works in C2 / Q3D visually, but is clunky as hell.. i wasted to much time on this thing years back, i don't recommend trying projecting 3d maps on 2d spheres with Construct. just use a 3d js library instead.

    Edited:

    ANYWAY.... here is a c3 project test pool for the glslSphere... its choppy, i can't make the flags to toggle at the right time for the ball... maybe someone can fix it but is where i got stuck a long time ago... with more or less "smoothness" but overall same choppines.

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