Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] Rotation 180º Char [FrontEnd]

Joined
Apr 23, 2013
Messages
1,172
Reaction score
1,737
Demo:

Find

Code:
static int LoginMenuExitFlag = 0;

and add code below!
Code:
static float playerRot = 0;
Find

Code:
m_Player->SetPosition(playerPosCreate);

and add code below!
In red text you can edit and put other key.
Code:
 int mMX=Mouse->m_MouseMoveX;    float glb_MouseSensAdj = 1.0f;  // in range (0.1 - 1.0)    float mmoveX = float(-mMX) * glb_MouseSensAdj;    [COLOR=#ff0000]if( Mouse->IsPressed(r3dMouse::mRightButton) ) [/COLOR]   {        playerRot += mmoveX;         if(playerRot > 180)  playerRot = 180;        if(playerRot < -180) playerRot = -180;    }
Find

Code:
m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = 0;

and replace this code
Code:
m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = playerRot;


Credits: I do not remember, call me for real credit​
 
Joined
Apr 2, 2013
Messages
1,098
Reaction score
4,469
Nothing to do I did this Ducking code like this a two or three years ago with mouse position manipulation and with object manipulation only rotates if the mouse is over the area or over the object

Here is only with the mouse position manipulation

Search for:
Code:
m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = 0;

Modify to:
Code:
if(Mouse->IsPressed(r3dMouse::mLeftButton)) // Rotação do Personagem By Yuri-BR
    {
        extern     PlayerStateVars_s CurrentRig;
        float  glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat();    


        int mmX = Mouse->m_MouseMoveX;
        int mmY = Mouse->m_MouseMoveY;


        float moveX = float(-mmX) * glb_MouseSensAdj;
        float moveY = float(-mmY) * glb_MouseSensAdj;


        int mx, my;
        Mouse->GetXY(mx, my);


        if(mx >= 400 && mx <= 900 && my >= 100 && my <= 700)
            m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation += moveX;


        if(m_Player->m_fPlayerRotationTarget > 180)  
            m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = 180;
        if(m_Player->m_fPlayerRotationTarget < -180)  
            m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = -180;


    }

With object manipulation I can not find...
 
Last edited:
Experienced Elementalist
Joined
May 28, 2017
Messages
225
Reaction score
127
lul thats my code...

Code:
if (Mouse->IsPressed(r3dMouse::mRightButton))
    {
        save = 1;

        r3dVector CamPos(0,0,0);
        int mMX=Mouse->m_MouseMoveX;
        float  glb_MouseSensAdj = g_mouse_sensitivity->GetFloat();

        static float camangle = 0;
                    
        camangle += float(-mMX) * glb_MouseSensAdj;

        if(m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation > 360.0f ) m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = 0.0f;
        if(m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation < -0.0f )   m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = -0.0f;

        m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = -camangle;
    }
 
Skilled Illusionist
Joined
Nov 27, 2018
Messages
335
Reaction score
65
lul thats my code...

Code:
if (Mouse->IsPressed(r3dMouse::mRightButton))
    {
        save = 1;

        r3dVector CamPos(0,0,0);
        int mMX=Mouse->m_MouseMoveX;
        float  glb_MouseSensAdj = g_mouse_sensitivity->GetFloat();

        static float camangle = 0;
                    
        camangle += float(-mMX) * glb_MouseSensAdj;

        if(m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation > 360.0f ) m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = 0.0f;
        if(m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation < -0.0f )   m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = -0.0f;

        m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = -camangle;
    }

change it

BsFfwYN - [Tutorial] Rotation 180º Char [FrontEnd] - RaGEZONE Forums


code:
m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = -camangle;
}

add after:

else
m_Player->m_fPlayerRotationTarget = m_Player->m_fPlayerRotation = 0;
 

Attachments

You must be registered for see attachments list
Newbie Spellweaver
Joined
Nov 28, 2022
Messages
31
Reaction score
5
C++:
int mMX = Fare->m_MouseMoveX; float glb_MouseSensAdj = 1.0f; // 0.1 ile 1.0 arasında float mmoveX = static_cast<float>(-mMX) * glb_MouseSensAdj; if (Mouse->IsPressed(r3dMouse::mRightButton)) { playerRot += mmoveX; if (playerRot > 180) playerRot = 180; if (playerRot < -180) playerRot = -180; } else if(m_needPlayerRenderingRequest==3) // oyun ekranını oyna m_Player->SetPosition(playerPosCreate);
Add this instead of this code and the character will return to its previous state after being thinned
C++:
// Target rotation value
float targetRot = 0.0f;
// Rotation speed (adjustable)
float rotationSpeed = 1.0f;

if (!Mouse->IsPressed(r3dMouse::mRightButton)) {
    // If the character's rotation is different from the target rotation, reverse the rotation movement
    if (playerRot != targetRot) {
        // Determine the direction of rotation
        float rotationDirection = (playerRot > targetRot) ? -1.0f : 1.0f;
        // Update the rotation
        playerRot += rotationSpeed * rotationDirection;

        // If the rotation speed is slow and it's approximately close to the target, lock the rotation to zero
        if (fabs(playerRot - targetRot) < rotationSpeed) {
            playerRot = targetRot;
        }
    }
}

int mMX = Mouse->m_MouseMoveX;
float glb_MouseSensAdj = 1.0f;
float mmoveX = static_cast<float>(-mMX) * glb_MouseSensAdj;

if (Mouse->IsPressed(r3dMouse::mRightButton)) {
    playerRot += mmoveX;
    if (playerRot > 180) playerRot = 180;
    if (playerRot < -180) playerRot = -180;
}
 
Last edited:
Back
Top