I am trying to move a player in direction angle by speed. I need to use trigonometric functions in order to calculate this. Can anyone help me discover how to do this?

``````if (playerB.up == true) {
(playerB.speed)+=((Delta*ballspeed)/1000);
}
if (playerB.down == true) {
(playerB.speed)-=((Delta*ballspeed)/1000);
}
if (playerB.left == true) {
(playerB.angle)-=((Delta*ballspeed)/1000);
}
if (playerB.right == true) {
(playerB.angle)+=((Delta*ballspeed)/1000);
}
//move player in direction angle by speed``````
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Tigran

>> I am trying to move a player in direction angle by speed

I am kind of hesitant of what you mean exactly by that, can you explain?

Why don't you do it with vectors? it's alot less work.
Just define a vector with a specified length (your speed) and use a rotation matrix to rotate it the amout of degrees.
Then add each component of the vector to your position.

Just google on the terms vector and rotation matrix and read wikipedia. that should be enough.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.