Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Moving towards direction of rotation.  (Read 1010 times)

0 Members and 1 Guest are viewing this topic.

Barji

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Moving towards direction of rotation.
« 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);
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Moving towards direction of rotation.
« Reply #1 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. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything