Public Group

# Ball can't roll straight in perspective

This topic is 3116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to make a soccer game, faking 3D. My ball object has an x, y and z property wich I can influence by speedX/Y/Z, wind and gravity All the physics work just fine and when I plot the ball out in 2D spaces showing Top, Front or Side view the result is just as wanted. The perspective used in the game looks like this : http://www.simoenss.be/perspectiveproblem/problemImg1.jpg When moving the ball I calculate the speed for x/y and z like this : speedX = (targetX - currentX)/framecount same for y and z speeds now when I move the ball, all the values are correct, I can verify that by watching my 2D views But on the perspective view the ball seems to curve when a straight line is expected. Like this : http://www.simoenss.be/perspectiveproblem/problemImg2.jpg To show the ball on screen I need to translate the x, y and z positions of the ball to the normal x and y position flash can handle. It is this translation that must be wrong. What is the correct way to translate these x, y and z positions to x and y positions with this kind of perspective?

##### Share on other sites
I don't know what axes you have x, y, and z assigned to. It looks like you might be mixing 2 axes up, subtracting from x to compensate for height when you should presumably be subtracting from y. What is your existing formula for calculating the position? (Your speed formula is irrelevant here - only the position matters.)

You could use a proper projection transform for this, although if I were doing this myself I'd probably just use linear interpolation to find the position perpendicular to the ground and then add an offset based on height, again linearly interpolated to simulate perspective.

##### Share on other sites
Hey Kylotan,

Is it possible he is seeing a "fish bowl" effect like how in many games, things kinda distort as they go to the edge of the screen?

##### Share on other sites
Maybe the linear interpolation is the problem. Maybe the OP is calculating the up direction (on screen) with a simple linear interpolation, instead of the perspective division/logarithmic thingy.

[Edited by - szecs on April 30, 2010 10:39:04 AM]

##### Share on other sites
Thanks for the reply, I'll see into it

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633271
• Total Posts
3011160
• ### Who's Online (See full list)

There are no registered users currently online

×