Hi,
As I understand it, sf::Transform should be used for any transform operations that are not covered by the higher level sf::Transformable 'helper' class. My issue is as follows:
In my game I have a boat, on board the boat is a selection of 'crew members' which I would like to move freely around said boat. Effectively I want to 'glue' the crew member to the boat. Originally I did this by setting the crew's position to boat's position + an offset, however this felt wrong and although it did partly work obviously when the ship rotate the crew members do not. I've come to the conclusion that I must somehow 'merge' the boat and crew member's transform, but I'm not sure exactly how to go about it. Technically I want to set the origin of the crew member to that of the boat.
This is what I have so far:
void CrewMember::update()
{
//Glue the crew member to the boat.
sf::Transform boat = m_pVessel->m_decks[0].getTransform(); //The boat the crew member is on.
sf::Transform crew = m_avatar.getTransform();
crew = crew.combine(boat); //Merge the transforms?
m_avatar.setPosition(crew.transformPoint(m_avatar.getPosition())); //Update the crew member to the correct position.
}
So far I've had no luck, any suggestions?
Thanks in advance!