Search code examples
unity-game-enginegame-physicsphysicsbounceisometric

Bouncing ball on isometric line


I am trying to simulate the bouncing ball effect on unity for my isometric game. I got a code to make that and it works fine from this link: https://physics.stackexchange.com/questions/256468/model-formula-for-bouncing-ball#:~:text=The%20coefficient%20of%20restitution%20is,ball%20it%20is%20around%200.75.

I want to convert the resulting movement, namely the (h) to iso. I end up with this two-equation

        // Walk from current postion in ISO line
          transform.position = new Vector2(transform.position.x + oneCellSize, 
              transform.position.y + (oneCellSize * IsoRatio));

        // Perfect bouncing effect on ISO line but in wrong position
          transform.position = new Vector2(transform.position.x + 0.02f, 
            (transform.position.x + oneCellSize) * IsoRatio +  BallHightOnTime );

But I failed to merge them together as the second one is using the x position. When I tried to change to y, it just moves in a crazy way.


Solution

  • Using some of your help guyz, I have come up with a solution to my problem by creating a separate vector that moves according to the ISO line and then assigns it to the ball position after adding the calculated hight.

    Thank you guys for your help.