1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

Slightly simplified path calculation

This commit is contained in:
mordred 2019-01-24 13:15:30 +01:00
parent be846a76f0
commit 6eb1ebaa0a

View file

@ -179,19 +179,14 @@ void Sapphire::Entity::BNpc::step()
} }
// This is probably not a good way to do it but works fine for now // This is probably not a good way to do it but works fine for now
float rot = Util::calcAngFrom( getPos().x, getPos().z, stepPos.x, stepPos.z );
float newRot = PI - rot + ( PI / 2 );
face( stepPos );
float angle = Util::calcAngFrom( getPos().x, getPos().z, stepPos.x, stepPos.z ) + PI; float angle = Util::calcAngFrom( getPos().x, getPos().z, stepPos.x, stepPos.z ) + PI;
auto x = ( cosf( angle ) * 1.1f ); auto x = ( cosf( angle ) * 1.1f );
auto y = ( getPos().y + stepPos.y ) * 0.5f; // Get speed from somewhere else? auto y = stepPos.y;
auto z = ( sinf( angle ) * 1.1f ); auto z = ( sinf( angle ) * 1.1f );
Common::FFXIVARR_POSITION3 newPos{ getPos().x + x, y, getPos().z + z }; setPos( { getPos().x + x, y, getPos().z + z } );
setPos( newPos ); face( stepPos );
setRot( newRot );
sendPositionUpdate(); sendPositionUpdate();
} }