Question Fixing movement after changing angles in usercmd

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

norgor

Newbie
Full Member
Jul 30, 2012
23
272
0
When i change angles in usercmd the player walks the wrong way, which makes 100% sense.
I've been asking lots of people, but i couldn't find anything. Therefore im asking you guys...
How do i calculate the forwardmove and sidemove to be correct after i changed the angles?

Right now this is my code, but it doesnt work.
C++:
		//Old angles and movement
		Vector oldviewangles = pCmd->viewangles;
		float oldsidemove = pCmd->sidemove;
		float oldforwardmove = pCmd->forwardmove;
		float oldupmove = pCmd->upmove;

                Vector aimangles = aimat(0.0f,0.0f,0.0f);


                pCmd->viewangles.X = aimangles.X;
		pCmd->viewangles.Y = aimangles.Y;
		pCmd->viewangles.Z = aimangles.Z;

		float delta = pCmd->viewangles.Y - oldviewangles.Y;
		
		pCmd->forwardmove = (sin(delta * (M_PI / 180.0f)) * oldforwardmove) + (cos(delta* (M_PI / 180.0f)) * oldsidemove);
		pCmd->sidemove = (cos(delta * (M_PI / 180.0f)) * oldforwardmove) - (sin(delta * (M_PI / 180.0f)) * oldsidemove);
All help will be greatly appreciated! :)
 
Last edited:

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Hey what game is this.
When i did this I had to make sure the angles dont get too high. Otherwise i also had random behaviour.
 

norgor

Newbie
Full Member
Jul 30, 2012
23
272
0
Isnt it 180 max angle? and -180 min?
for X axis ^
and for Y axis is 89 -89
Fixed that, but it still doesnt work.
PS. 89 isn't the max angle for Y axis, if you go above it just turns the view upside-down. Which is actually perfectly fine. All angles are -180.0f to 180.0f if you go above that they just subtract 360.0f from it. So you basically start at -180.0f again.
 
Last edited:
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods