# Object Velocity

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

## Recommended Posts

CAn someone tell me if this equation looks right. Im moving a ball on an x any y axis like this. Ball.x += cosf(BallAngle * PI / 180) * Ball.xv / 60; Is there anything fishy about this?

##### Share on other sites
Quote:
 Original post by BluseedCAn someone tell me if this equation looks right.Im moving a ball on an x any y axis like this.Ball.x += cosf(BallAngle * PI / 180) * Ball.xv / 60; Is there anything fishy about this?
It should probably look more like this:
Ball.x += cos(BallAngle * PI / 180.0f) * Ball.speed * timeStep;Ball.y += sin(BallAngle * PI / 180.0f) * Ball.speed * timeStep;
There are other improvements that could be made as well, such as using vector rather than per-component notation.

##### Share on other sites
Vector instead of pre-component notation? Can you explain a little more?

##### Share on other sites
Quote:
 Original post by BluseedVector instead of pre-component notation? Can you explain a little more?
It's generally easier to work with geometric vectors as a class or struct of which the vector components are member variables, rather than individual variables as you're doing. Check out the articles section here for some introductory articles on vector and matrix math (you should be able to find some example code as well).

##### Share on other sites
Damn That is beautiful i never seen that section of GDNET, i feel like an asshole!! lol thx i think thats the best help ever..

1. 1
Rutin
70
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633422
• Total Posts
3011804
• ### Who's Online (See full list)

There are no registered users currently online

×