SFML community forums

Help => General => Topic started by: Barji on November 01, 2020, 05:59:08 pm

Title: Moving towards direction of rotation.
Post by: Barji on November 01, 2020, 05:59:08 pm
There have been questions posted on this in the past but some are contradictory and I'm having trouble abstracting. I've successfully got my player moving in the direction of the player however It follows a sin/cos path when moving. I'm relatively new and was wondering if i could be pointed in the right direction.
I imagine it has something to do with my DeltaTime or velocity as their values are changing.

void Movement()
{
        direction.x = sin(DegToRad(playerSprite.getRotation()));
        direction.y = -cos(DegToRad(playerSprite.getRotation()));

        playerSprite.move(direction.x * velocity.x * Delta_Time() * movementSpeed, direction.y * velocity.y * Delta_Time() * movementSpeed);
}
 
Title: Re: Moving towards direction of rotation.
Post by: eXpl0it3r on November 28, 2020, 11:56:42 am
Can you describe in more detail what you're trying to do?
Also if you've already found some releated threads, make sure to link them. :)